@mage-ui/components 0.0.94 → 0.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.d.ts","names":[],"sources":["../../../../src/components/controls/dropdown/Combobox.tsx"],"sourcesContent":[],"mappings":";;;;;;KAkBY,aAAA,GAAgB,KAC1B,qEAGA,KAAK;;;IAJK,KAAA,EAAA,MAAa;EAAA,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA;SACvB,EAAA;IAD0B,EAAA,EAAA,MAAA,GAAA,MAAA;IAIrB,KAAA,EAAA,MAAA;KAAL;WAakB,CAAA,EAAA,OAAA;EAAS,UAAA,CAAA,EAAA;IAKhB,MAAA,CAiGZ,EAAA,MAAA;IAAA,KAAA,CAAA,EAAA,MAAA;IAjGwB,MAAA,CAAA,EAAA,MAAA;;QAAA,CAAA,EAAA,MAAA;OAAA,CAAA,EAAA,MAAA,GAAA,IAAA;SAAA,CAAA,EALX,KAAA,CAAM,SAKK;aAAA,CAAA,EAAA,OAAA;eAAA,CAAA,EAAA,MAAA;;AAAA,cAAZ,QAAY,EAAA,CAAA;EAAA,aAAA;EAAA,SAAA;EAAA,iBAAA;EAAA,cAAA;EAAA,OAAA;EAAA,OAAA;EAAA,UAAA;EAAA,MAAA;EAAA,KAAA;EAAA,WAAA;EAAA,aAAA;EAAA,GAAA;AAAA,CAAA,EAatB,aAbsB,EAAA,GAaT,kBAAA,CAAA,GAAA,CAAA,OAbS"}
1
+ {"version":3,"file":"Combobox.d.ts","names":[],"sources":["../../../../src/components/controls/dropdown/Combobox.tsx"],"sourcesContent":[],"mappings":";;;;;;KAkBY,aAAA,GAAgB,KAC1B,qEAGA,KAAK;;;IAJK,KAAA,EAAA,MAAa;EAAA,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA;SACvB,EAAA;IAD0B,EAAA,EAAA,MAAA,GAAA,MAAA;IAIrB,KAAA,EAAA,MAAA;KAAL;WAakB,CAAA,EAAA,OAAA;EAAS,UAAA,CAAA,EAAA;IAKhB,MAAA,CAmGZ,EAAA,MAAA;IAAA,KAAA,CAAA,EAAA,MAAA;IAnGwB,MAAA,CAAA,EAAA,MAAA;;QAAA,CAAA,EAAA,MAAA;OAAA,CAAA,EAAA,MAAA,GAAA,IAAA;SAAA,CAAA,EALX,KAAA,CAAM,SAKK;aAAA,CAAA,EAAA,OAAA;eAAA,CAAA,EAAA,MAAA;;AAAA,cAAZ,QAAY,EAAA,CAAA;EAAA,aAAA;EAAA,SAAA;EAAA,iBAAA;EAAA,cAAA;EAAA,OAAA;EAAA,OAAA;EAAA,UAAA;EAAA,MAAA;EAAA,KAAA;EAAA,WAAA;EAAA,aAAA;EAAA,GAAA;AAAA,CAAA,EAatB,aAbsB,EAAA,GAaT,kBAAA,CAAA,GAAA,CAAA,OAbS"}
@@ -1,2 +1,2 @@
1
- import{Icon as e}from"../../data-display/icons/icon/Icon.js";import{DropdownBase as t}from"./DropdownBase.js";import{InputText as n}from"../input-text/InputText.js";import{clearSection as r,comboboxEmpty as i,comboboxOption as a,dropdown as o,icon as s,inputSection as c,selectSection as l}from"@mage-ui/styled-system/recipes";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{useState as f}from"react";import{cx as p}from"@mage-ui/styled-system/css";const m=({defaultOpened:m=!1,creatable:h,setSelectedOption:g,selectedOption:_,endSlot:v,options:y,classNames:b,create:x,empty:S,isClearable:C,clearableIcon:w,...T})=>{let[E,D]=f(_?.value??``),O=(y.every(e=>e.value!==E)?y.filter(e=>e.value.toLowerCase().includes(E.toLowerCase().trim())):y).map(e=>u(t.Option,{value:e.value,active:_?.id===e.id,classNames:{option:b?.option??a()},children:e.value},e.id)),k=()=>h&&E?d(t.Option,{value:E,classNames:{option:b?.create??a({type:`create`})},children:[u(e,{name:`plus`,classNames:s({size:`m`})}),`${x??`Create`} '${E}'`]},E):S!==null&&u(t.Empty,{classNames:{empty:b?.empty??i()},children:S??`Nothing found`}),A=e=>{let t=y.find(t=>t.value===e);!t&&h&&e&&(t={id:`new`,value:e}),g(t)};return u(t,{classNames:{dropdown:S===null?``:o()},readOnly:!1,target:u(n,{value:E,classNames:{section:b?.section??p(c(),C&&E?r():l())},...T}),selectedOption:_,setQuery:D,setSelectedOption:e=>A(e),endSlot:v,width:`target`,isClearable:C,clearableIcon:w,children:O.length>0?O:u(k,{})})};export{m as Combobox};
1
+ import{Icon as e}from"../../data-display/icons/icon/Icon.js";import{DropdownBase as t}from"./DropdownBase.js";import{InputText as n}from"../input-text/InputText.js";import{clearSection as r,comboboxEmpty as i,comboboxOption as a,dropdown as o,icon as s,inputSection as c,selectSection as l}from"@mage-ui/styled-system/recipes";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{useState as f}from"react";import{cx as p}from"@mage-ui/styled-system/css";const m=({defaultOpened:m=!1,creatable:h,setSelectedOption:g,selectedOption:_,endSlot:v,options:y,classNames:b,create:x,empty:S,isClearable:C,clearableIcon:w,...T})=>{let[E,D]=f(_?.value??``),O=(y.every(e=>e.value!==E)?y.filter(e=>e.value.toLowerCase().includes(E.toLowerCase().trim())):y).map(e=>u(t.Option,{value:e.value,active:_?.id===e.id,classNames:{option:b?.option??a()},children:e.value},e.id)),k=()=>h&&E?d(t.Option,{value:E,classNames:{option:b?.create??a({type:`create`})},children:[u(e,{name:`plus`,classNames:s({size:`m`})}),`${x??`Create`} '${E}'`]},E):S!==null&&u(t.Empty,{classNames:{empty:b?.empty??i()},children:S??`Nothing found`}),A=e=>{let t=y.find(t=>t.value===e);!t&&h&&e&&(t={id:`new`,value:e}),g(t)},j=O.length>0||S!==null||h&&E;return u(t,{classNames:{dropdown:j?o():``},readOnly:!1,target:u(n,{value:E,classNames:{section:b?.section??p(c(),C&&E?r():l())},...T}),selectedOption:_,setQuery:D,setSelectedOption:e=>A(e),endSlot:v,width:`target`,isClearable:C,clearableIcon:w,children:j&&(O.length>0?O:u(k,{}))})};export{m as Combobox};
2
2
  //# sourceMappingURL=Combobox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","names":[],"sources":["../../../../src/components/controls/dropdown/Combobox.tsx"],"sourcesContent":["import type React from 'react';\nimport { useState } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n clearSection,\n comboboxEmpty,\n comboboxOption,\n dropdown,\n icon,\n inputSection,\n selectSection,\n} from '@mage-ui/styled-system/recipes';\nimport { InputText, type InputTextProps } from '@/components/controls';\nimport { Icon } from '@/components/data-display';\n\nimport { DropdownBase, type DropdownBaseProps } from './DropdownBase';\n\nexport type ComboboxProps = Omit<\n DropdownBaseProps,\n 'children' | 'onClick' | 'setQuery' | 'target'\n> &\n Omit<InputTextProps, 'isClearable' | 'clearableIcon'> & {\n setSelectedOption: (\n option: { id: string | number; value: string } | undefined,\n ) => void;\n options: { id: string | number; value: string }[];\n creatable?: boolean;\n classNames?: {\n option?: string;\n empty?: string;\n create?: string;\n };\n create?: string;\n empty?: string | null;\n endSlot?: React.ReactNode;\n isClearable?: boolean;\n clearableIcon?: string;\n };\n\nexport const Combobox = ({\n defaultOpened = false,\n creatable,\n setSelectedOption,\n selectedOption,\n endSlot,\n options,\n classNames,\n create,\n empty,\n isClearable,\n clearableIcon,\n ...props\n}: ComboboxProps) => {\n const [query, setQuery] = useState(selectedOption?.value ?? '');\n\n const shouldFilterOptions = options.every((item) => item.value !== query);\n const filteredOptions = shouldFilterOptions\n ? options.filter((item) =>\n item.value.toLowerCase().includes(query.toLowerCase().trim()),\n )\n : options;\n\n const dropdownOptions = filteredOptions.map((option) => (\n <DropdownBase.Option\n value={option.value}\n key={option.id}\n active={selectedOption?.id === option.id}\n classNames={{ option: classNames?.option ?? comboboxOption() }}\n >\n {option.value}\n </DropdownBase.Option>\n ));\n\n const MissingOption = () => {\n if (creatable && query) {\n return (\n <DropdownBase.Option\n value={query}\n key={query}\n classNames={{\n option: classNames?.create ?? comboboxOption({ type: 'create' }),\n }}\n >\n <Icon name='plus' classNames={icon({ size: 'm' })} />\n {`${create ?? 'Create'} '${query}'`}\n </DropdownBase.Option>\n );\n }\n return (\n empty !== null && (\n <DropdownBase.Empty\n classNames={{ empty: classNames?.empty ?? comboboxEmpty() }}\n >\n {empty ?? 'Nothing found'}\n </DropdownBase.Empty>\n )\n );\n };\n\n const onChange = (value: string | undefined) => {\n let selected = options.find((item) => item.value === value);\n if (!selected && creatable && value) {\n selected = { id: 'new', value };\n }\n setSelectedOption(selected);\n };\n\n return (\n <DropdownBase\n classNames={{ dropdown: empty === null ? '' : dropdown() }}\n readOnly={false}\n target={\n <InputText\n value={query}\n classNames={{\n section:\n classNames?.section ??\n cx(\n inputSection(),\n isClearable && query ? clearSection() : selectSection(),\n ),\n }}\n {...props}\n />\n }\n selectedOption={selectedOption}\n setQuery={setQuery}\n setSelectedOption={(option) => onChange(option)}\n endSlot={endSlot}\n width='target'\n isClearable={isClearable}\n clearableIcon={clearableIcon}\n >\n {dropdownOptions.length > 0 ? dropdownOptions : <MissingOption />}\n </DropdownBase>\n );\n};\n"],"mappings":"0cAwCA,MAAa,GAAY,CACvB,gBAAgB,GAChB,YACA,oBACA,iBACA,UACA,UACA,aACA,SACA,QACA,cACA,gBACA,GAAG,KACgB,CACnB,GAAM,CAAC,EAAO,GAAY,EAAS,GAAgB,OAAS,GAAG,CASzD,GAPsB,EAAQ,MAAO,GAAS,EAAK,QAAU,EAAM,CAErE,EAAQ,OAAQ,GACd,EAAK,MAAM,aAAa,CAAC,SAAS,EAAM,aAAa,CAAC,MAAM,CAAC,CAC9D,CACD,GAEoC,IAAK,GAC3C,EAAC,EAAa,OAAA,CACZ,MAAO,EAAO,MAEd,OAAQ,GAAgB,KAAO,EAAO,GACtC,WAAY,CAAE,OAAQ,GAAY,QAAU,GAAgB,CAAE,UAE7D,EAAO,OAJH,EAAO,GAKQ,CACtB,CAEI,MACA,GAAa,EAEb,EAAC,EAAa,OAAA,CACZ,MAAO,EAEP,WAAY,CACV,OAAQ,GAAY,QAAU,EAAe,CAAE,KAAM,SAAU,CAAC,CACjE,WAED,EAAC,EAAA,CAAK,KAAK,OAAO,WAAY,EAAK,CAAE,KAAM,IAAK,CAAC,EAAI,CACpD,GAAG,GAAU,SAAS,IAAI,EAAM,GAAA,EAN5B,EAOe,CAIxB,IAAU,MACR,EAAC,EAAa,MAAA,CACZ,WAAY,CAAE,MAAO,GAAY,OAAS,GAAe,CAAE,UAE1D,GAAS,iBACS,CAKrB,EAAY,GAA8B,CAC9C,IAAI,EAAW,EAAQ,KAAM,GAAS,EAAK,QAAU,EAAM,CACvD,CAAC,GAAY,GAAa,IAC5B,EAAW,CAAE,GAAI,MAAO,QAAO,EAEjC,EAAkB,EAAS,EAG7B,OACE,EAAC,EAAA,CACC,WAAY,CAAE,SAAU,IAAU,KAAO,GAAK,GAAU,CAAE,CAC1D,SAAU,GACV,OACE,EAAC,EAAA,CACC,MAAO,EACP,WAAY,CACV,QACE,GAAY,SACZ,EACE,GAAc,CACd,GAAe,EAAQ,GAAc,CAAG,GAAe,CACxD,CACJ,CACD,GAAI,GACJ,CAEY,iBACN,WACV,kBAAoB,GAAW,EAAS,EAAO,CACtC,UACT,MAAM,SACO,cACE,yBAEd,EAAgB,OAAS,EAAI,EAAkB,EAAC,EAAA,EAAA,CAAgB,EACpD"}
1
+ {"version":3,"file":"Combobox.js","names":[],"sources":["../../../../src/components/controls/dropdown/Combobox.tsx"],"sourcesContent":["import type React from 'react';\nimport { useState } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n clearSection,\n comboboxEmpty,\n comboboxOption,\n dropdown,\n icon,\n inputSection,\n selectSection,\n} from '@mage-ui/styled-system/recipes';\nimport { InputText, type InputTextProps } from '@/components/controls';\nimport { Icon } from '@/components/data-display';\n\nimport { DropdownBase, type DropdownBaseProps } from './DropdownBase';\n\nexport type ComboboxProps = Omit<\n DropdownBaseProps,\n 'children' | 'onClick' | 'setQuery' | 'target'\n> &\n Omit<InputTextProps, 'isClearable' | 'clearableIcon'> & {\n setSelectedOption: (\n option: { id: string | number; value: string } | undefined,\n ) => void;\n options: { id: string | number; value: string }[];\n creatable?: boolean;\n classNames?: {\n option?: string;\n empty?: string;\n create?: string;\n };\n create?: string;\n empty?: string | null;\n endSlot?: React.ReactNode;\n isClearable?: boolean;\n clearableIcon?: string;\n };\n\nexport const Combobox = ({\n defaultOpened = false,\n creatable,\n setSelectedOption,\n selectedOption,\n endSlot,\n options,\n classNames,\n create,\n empty,\n isClearable,\n clearableIcon,\n ...props\n}: ComboboxProps) => {\n const [query, setQuery] = useState(selectedOption?.value ?? '');\n\n const shouldFilterOptions = options.every((item) => item.value !== query);\n const filteredOptions = shouldFilterOptions\n ? options.filter((item) =>\n item.value.toLowerCase().includes(query.toLowerCase().trim()),\n )\n : options;\n\n const dropdownOptions = filteredOptions.map((option) => (\n <DropdownBase.Option\n value={option.value}\n key={option.id}\n active={selectedOption?.id === option.id}\n classNames={{ option: classNames?.option ?? comboboxOption() }}\n >\n {option.value}\n </DropdownBase.Option>\n ));\n\n const MissingOption = () => {\n if (creatable && query) {\n return (\n <DropdownBase.Option\n value={query}\n key={query}\n classNames={{\n option: classNames?.create ?? comboboxOption({ type: 'create' }),\n }}\n >\n <Icon name='plus' classNames={icon({ size: 'm' })} />\n {`${create ?? 'Create'} '${query}'`}\n </DropdownBase.Option>\n );\n }\n return (\n empty !== null && (\n <DropdownBase.Empty\n classNames={{ empty: classNames?.empty ?? comboboxEmpty() }}\n >\n {empty ?? 'Nothing found'}\n </DropdownBase.Empty>\n )\n );\n };\n\n const onChange = (value: string | undefined) => {\n let selected = options.find((item) => item.value === value);\n if (!selected && creatable && value) {\n selected = { id: 'new', value };\n }\n setSelectedOption(selected);\n };\n const showDropdown =\n dropdownOptions.length > 0 || empty !== null || (creatable && query);\n return (\n <DropdownBase\n classNames={{ dropdown: showDropdown ? dropdown() : '' }}\n readOnly={false}\n target={\n <InputText\n value={query}\n classNames={{\n section:\n classNames?.section ??\n cx(\n inputSection(),\n isClearable && query ? clearSection() : selectSection(),\n ),\n }}\n {...props}\n />\n }\n selectedOption={selectedOption}\n setQuery={setQuery}\n setSelectedOption={(option) => onChange(option)}\n endSlot={endSlot}\n width='target'\n isClearable={isClearable}\n clearableIcon={clearableIcon}\n >\n {showDropdown &&\n (dropdownOptions.length > 0 ? dropdownOptions : <MissingOption />)}\n </DropdownBase>\n );\n};\n"],"mappings":"0cAwCA,MAAa,GAAY,CACvB,gBAAgB,GAChB,YACA,oBACA,iBACA,UACA,UACA,aACA,SACA,QACA,cACA,gBACA,GAAG,KACgB,CACnB,GAAM,CAAC,EAAO,GAAY,EAAS,GAAgB,OAAS,GAAG,CASzD,GAPsB,EAAQ,MAAO,GAAS,EAAK,QAAU,EAAM,CAErE,EAAQ,OAAQ,GACd,EAAK,MAAM,aAAa,CAAC,SAAS,EAAM,aAAa,CAAC,MAAM,CAAC,CAC9D,CACD,GAEoC,IAAK,GAC3C,EAAC,EAAa,OAAA,CACZ,MAAO,EAAO,MAEd,OAAQ,GAAgB,KAAO,EAAO,GACtC,WAAY,CAAE,OAAQ,GAAY,QAAU,GAAgB,CAAE,UAE7D,EAAO,OAJH,EAAO,GAKQ,CACtB,CAEI,MACA,GAAa,EAEb,EAAC,EAAa,OAAA,CACZ,MAAO,EAEP,WAAY,CACV,OAAQ,GAAY,QAAU,EAAe,CAAE,KAAM,SAAU,CAAC,CACjE,WAED,EAAC,EAAA,CAAK,KAAK,OAAO,WAAY,EAAK,CAAE,KAAM,IAAK,CAAC,EAAI,CACpD,GAAG,GAAU,SAAS,IAAI,EAAM,GAAA,EAN5B,EAOe,CAIxB,IAAU,MACR,EAAC,EAAa,MAAA,CACZ,WAAY,CAAE,MAAO,GAAY,OAAS,GAAe,CAAE,UAE1D,GAAS,iBACS,CAKrB,EAAY,GAA8B,CAC9C,IAAI,EAAW,EAAQ,KAAM,GAAS,EAAK,QAAU,EAAM,CACvD,CAAC,GAAY,GAAa,IAC5B,EAAW,CAAE,GAAI,MAAO,QAAO,EAEjC,EAAkB,EAAS,EAEvB,EACJ,EAAgB,OAAS,GAAK,IAAU,MAAS,GAAa,EAChE,OACE,EAAC,EAAA,CACC,WAAY,CAAE,SAAU,EAAe,GAAU,CAAG,GAAI,CACxD,SAAU,GACV,OACE,EAAC,EAAA,CACC,MAAO,EACP,WAAY,CACV,QACE,GAAY,SACZ,EACE,GAAc,CACd,GAAe,EAAQ,GAAc,CAAG,GAAe,CACxD,CACJ,CACD,GAAI,GACJ,CAEY,iBACN,WACV,kBAAoB,GAAW,EAAS,EAAO,CACtC,UACT,MAAM,SACO,cACE,yBAEd,IACE,EAAgB,OAAS,EAAI,EAAkB,EAAC,EAAA,EAAA,CAAgB,GACtD"}
@@ -32,6 +32,7 @@ type DropdownBaseProps = {
32
32
  portal?: boolean;
33
33
  position?: 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end';
34
34
  width?: number | string;
35
+ keepMounted?: boolean;
35
36
  };
36
37
  //#endregion
37
38
  export { DropdownBaseProps };
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownBase.js","names":["MantineCombobox","Divider: React.FC<{ classNames?: { divider?: string } }>"],"sources":["../../../../src/components/controls/dropdown/DropdownBase.tsx"],"sourcesContent":["import { cloneElement } from 'react';\n\nimport {\n comboboxClear,\n comboboxDivider,\n comboboxOptions,\n dropdown,\n} from '@mage-ui/styled-system/recipes';\nimport { Combobox as MantineCombobox, useCombobox } from '@mantine/core';\nimport { ButtonIcon } from '@/components/buttons';\n\nexport type DropdownBaseProps = {\n defaultOpened?: boolean;\n readOnly?: boolean;\n setQuery?: (value: string) => void;\n selectedOption?: { id: string | number; value: string } | undefined;\n setSelectedOption: (value: string | undefined) => void;\n target: React.ReactElement<{\n startSlot?: React.ReactNode;\n endSlot?: React.ReactNode;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n onBlur?: () => void;\n onClick?: () => void;\n }>;\n classNames?: {\n dropdown?: string;\n options?: string;\n divider?: string;\n };\n endSlot?: React.ReactNode;\n startSlot?: React.ReactNode;\n isClearable?: boolean;\n clearableIcon?: string;\n children: React.ReactNode;\n portal?: boolean;\n position?:\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end';\n width?: number | string;\n};\n\nexport const DropdownBase = ({\n defaultOpened,\n readOnly,\n setQuery,\n setSelectedOption,\n selectedOption,\n target,\n classNames,\n children,\n endSlot,\n startSlot,\n position,\n portal,\n width,\n isClearable,\n clearableIcon,\n ...props\n}: DropdownBaseProps) => {\n const combobox = useCombobox({\n defaultOpened: defaultOpened ?? false,\n scrollBehavior: 'smooth',\n onDropdownClose: () => {\n combobox.resetSelectedOption();\n },\n });\n\n const handleClear = () => {\n setQuery?.('');\n setSelectedOption(undefined);\n combobox.resetSelectedOption();\n };\n const showClearButton = isClearable && (selectedOption?.value || '');\n\n const clearButton = (\n <ButtonIcon\n classNames={{\n root: comboboxClear(),\n }}\n icon={clearableIcon || 'x-close'}\n label='clear input'\n onClick={(e) => {\n e.stopPropagation();\n handleClear();\n }}\n />\n );\n\n const targetComponent = cloneElement(target, {\n ...(target?.props ?? {}),\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n target?.props?.onChange?.(event);\n setQuery?.(event.currentTarget.value);\n combobox.openDropdown();\n combobox.updateSelectedOptionIndex();\n },\n onBlur: () => {\n setQuery?.(selectedOption?.value ?? '');\n },\n onClick: () => {\n if (readOnly) {\n combobox.toggleDropdown();\n } else {\n combobox.openDropdown();\n }\n },\n // opened: combobox.isDropdownOpened,\n startSlot: startSlot,\n endSlot: showClearButton ? clearButton : endSlot,\n });\n\n return (\n <MantineCombobox\n readOnly={readOnly ?? false}\n onOptionSubmit={(option) => {\n setSelectedOption(option);\n setQuery?.(option);\n combobox.closeDropdown();\n }}\n store={combobox}\n withinPortal={portal || true}\n position={position || 'bottom-start'}\n width={width || 'auto'}\n {...props}\n >\n <MantineCombobox.Target>{targetComponent}</MantineCombobox.Target>\n <MantineCombobox.Dropdown\n classNames={{\n dropdown: classNames?.dropdown ?? dropdown(),\n }}\n >\n <MantineCombobox.Options\n classNames={{\n options: classNames?.options ?? comboboxOptions(),\n }}\n >\n {children}\n </MantineCombobox.Options>\n </MantineCombobox.Dropdown>\n </MantineCombobox>\n );\n};\n\nconst Divider: React.FC<{ classNames?: { divider?: string } }> = ({\n classNames,\n}) => {\n return (\n <hr\n className={classNames?.divider ?? comboboxDivider()}\n aria-orientation='horizontal'\n />\n );\n};\n\nDropdownBase.Option = MantineCombobox.Option;\nDropdownBase.Option.displayName = 'DropdownBase.Option';\nDropdownBase.Divider = Divider;\nDropdownBase.Divider.displayName = 'DropdownBase.Divider';\nDropdownBase.Empty = MantineCombobox.Empty;\nDropdownBase.Empty.displayName = 'DropdownBase.Empty';\n"],"mappings":"6UAmDA,MAAa,GAAgB,CAC3B,gBACA,WACA,WACA,oBACA,iBACA,SACA,aACA,WACA,UACA,YACA,WACA,SACA,QACA,cACA,gBACA,GAAG,KACoB,CACvB,IAAM,EAAW,EAAY,CAC3B,cAAe,GAAiB,GAChC,eAAgB,SAChB,oBAAuB,CACrB,EAAS,qBAAqB,EAEjC,CAAC,CAEI,MAAoB,CACxB,IAAW,GAAG,CACd,EAAkB,IAAA,GAAU,CAC5B,EAAS,qBAAqB,EAE1B,EAAkB,IAAgB,GAAgB,OAAS,IAE3D,EACJ,EAAC,EAAA,CACC,WAAY,CACV,KAAM,GAAe,CACtB,CACD,KAAM,GAAiB,UACvB,MAAM,cACN,QAAU,GAAM,CACd,EAAE,iBAAiB,CACnB,GAAa,GAEf,CAGE,EAAkB,EAAa,EAAQ,CAC3C,GAAI,GAAQ,OAAS,EAAE,CACvB,SAAW,GAA+C,CACxD,GAAQ,OAAO,WAAW,EAAM,CAChC,IAAW,EAAM,cAAc,MAAM,CACrC,EAAS,cAAc,CACvB,EAAS,2BAA2B,EAEtC,WAAc,CACZ,IAAW,GAAgB,OAAS,GAAG,EAEzC,YAAe,CACT,EACF,EAAS,gBAAgB,CAEzB,EAAS,cAAc,EAIhB,YACX,QAAS,EAAkB,EAAc,EAC1C,CAAC,CAEF,OACE,EAACA,EAAAA,CACC,SAAU,GAAY,GACtB,eAAiB,GAAW,CAC1B,EAAkB,EAAO,CACzB,IAAW,EAAO,CAClB,EAAS,eAAe,EAE1B,MAAO,EACP,aAAc,GAAU,GACxB,SAAU,GAAY,eACtB,MAAO,GAAS,OAChB,GAAI,YAEJ,EAACA,EAAgB,OAAA,CAAA,SAAQ,EAAA,CAAyC,CAClE,EAACA,EAAgB,SAAA,CACf,WAAY,CACV,SAAU,GAAY,UAAY,GAAU,CAC7C,UAED,EAACA,EAAgB,QAAA,CACf,WAAY,CACV,QAAS,GAAY,SAAW,GAAiB,CAClD,CAEA,YACuB,EACD,CAAA,EACX,EAIhBC,GAA4D,CAChE,gBAGE,EAAC,KAAA,CACC,UAAW,GAAY,SAAW,GAAiB,CACnD,mBAAiB,cACjB,CAIN,EAAa,OAASD,EAAgB,OACtC,EAAa,OAAO,YAAc,sBAClC,EAAa,QAAU,EACvB,EAAa,QAAQ,YAAc,uBACnC,EAAa,MAAQA,EAAgB,MACrC,EAAa,MAAM,YAAc"}
1
+ {"version":3,"file":"DropdownBase.js","names":["MantineCombobox","Divider: React.FC<{ classNames?: { divider?: string } }>"],"sources":["../../../../src/components/controls/dropdown/DropdownBase.tsx"],"sourcesContent":["import { cloneElement } from 'react';\n\nimport {\n comboboxClear,\n comboboxDivider,\n comboboxOptions,\n dropdown,\n} from '@mage-ui/styled-system/recipes';\nimport { Combobox as MantineCombobox, useCombobox } from '@mantine/core';\nimport { ButtonIcon } from '@/components/buttons';\n\nexport type DropdownBaseProps = {\n defaultOpened?: boolean;\n readOnly?: boolean;\n setQuery?: (value: string) => void;\n selectedOption?: { id: string | number; value: string } | undefined;\n setSelectedOption: (value: string | undefined) => void;\n target: React.ReactElement<{\n startSlot?: React.ReactNode;\n endSlot?: React.ReactNode;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n onBlur?: () => void;\n onClick?: () => void;\n }>;\n classNames?: {\n dropdown?: string;\n options?: string;\n divider?: string;\n };\n endSlot?: React.ReactNode;\n startSlot?: React.ReactNode;\n isClearable?: boolean;\n clearableIcon?: string;\n children: React.ReactNode;\n portal?: boolean;\n position?:\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end';\n width?: number | string;\n keepMounted?: boolean;\n};\n\nexport const DropdownBase = ({\n defaultOpened,\n readOnly,\n setQuery,\n setSelectedOption,\n selectedOption,\n target,\n classNames,\n children,\n endSlot,\n startSlot,\n position,\n portal,\n width,\n isClearable,\n clearableIcon,\n ...props\n}: DropdownBaseProps) => {\n const combobox = useCombobox({\n defaultOpened: defaultOpened ?? false,\n scrollBehavior: 'smooth',\n onDropdownClose: () => {\n combobox.resetSelectedOption();\n },\n });\n\n const handleClear = () => {\n setQuery?.('');\n setSelectedOption(undefined);\n combobox.resetSelectedOption();\n };\n const showClearButton = isClearable && (selectedOption?.value || '');\n\n const clearButton = (\n <ButtonIcon\n classNames={{\n root: comboboxClear(),\n }}\n icon={clearableIcon || 'x-close'}\n label='clear input'\n onClick={(e) => {\n e.stopPropagation();\n handleClear();\n }}\n />\n );\n\n const targetComponent = cloneElement(target, {\n ...(target?.props ?? {}),\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n target?.props?.onChange?.(event);\n setQuery?.(event.currentTarget.value);\n combobox.openDropdown();\n combobox.updateSelectedOptionIndex();\n },\n onBlur: () => {\n setQuery?.(selectedOption?.value ?? '');\n },\n onClick: () => {\n if (readOnly) {\n combobox.toggleDropdown();\n } else {\n combobox.openDropdown();\n }\n },\n // opened: combobox.isDropdownOpened,\n startSlot: startSlot,\n endSlot: showClearButton ? clearButton : endSlot,\n });\n\n return (\n <MantineCombobox\n readOnly={readOnly ?? false}\n onOptionSubmit={(option) => {\n setSelectedOption(option);\n setQuery?.(option);\n combobox.closeDropdown();\n }}\n store={combobox}\n withinPortal={portal || true}\n position={position || 'bottom-start'}\n width={width || 'auto'}\n {...props}\n >\n <MantineCombobox.Target>{targetComponent}</MantineCombobox.Target>\n <MantineCombobox.Dropdown\n classNames={{\n dropdown: classNames?.dropdown ?? dropdown(),\n }}\n >\n <MantineCombobox.Options\n classNames={{\n options: classNames?.options ?? comboboxOptions(),\n }}\n >\n {children}\n </MantineCombobox.Options>\n </MantineCombobox.Dropdown>\n </MantineCombobox>\n );\n};\n\nconst Divider: React.FC<{ classNames?: { divider?: string } }> = ({\n classNames,\n}) => {\n return (\n <hr\n className={classNames?.divider ?? comboboxDivider()}\n aria-orientation='horizontal'\n />\n );\n};\n\nDropdownBase.Option = MantineCombobox.Option;\nDropdownBase.Option.displayName = 'DropdownBase.Option';\nDropdownBase.Divider = Divider;\nDropdownBase.Divider.displayName = 'DropdownBase.Divider';\nDropdownBase.Empty = MantineCombobox.Empty;\nDropdownBase.Empty.displayName = 'DropdownBase.Empty';\n"],"mappings":"6UAoDA,MAAa,GAAgB,CAC3B,gBACA,WACA,WACA,oBACA,iBACA,SACA,aACA,WACA,UACA,YACA,WACA,SACA,QACA,cACA,gBACA,GAAG,KACoB,CACvB,IAAM,EAAW,EAAY,CAC3B,cAAe,GAAiB,GAChC,eAAgB,SAChB,oBAAuB,CACrB,EAAS,qBAAqB,EAEjC,CAAC,CAEI,MAAoB,CACxB,IAAW,GAAG,CACd,EAAkB,IAAA,GAAU,CAC5B,EAAS,qBAAqB,EAE1B,EAAkB,IAAgB,GAAgB,OAAS,IAE3D,EACJ,EAAC,EAAA,CACC,WAAY,CACV,KAAM,GAAe,CACtB,CACD,KAAM,GAAiB,UACvB,MAAM,cACN,QAAU,GAAM,CACd,EAAE,iBAAiB,CACnB,GAAa,GAEf,CAGE,EAAkB,EAAa,EAAQ,CAC3C,GAAI,GAAQ,OAAS,EAAE,CACvB,SAAW,GAA+C,CACxD,GAAQ,OAAO,WAAW,EAAM,CAChC,IAAW,EAAM,cAAc,MAAM,CACrC,EAAS,cAAc,CACvB,EAAS,2BAA2B,EAEtC,WAAc,CACZ,IAAW,GAAgB,OAAS,GAAG,EAEzC,YAAe,CACT,EACF,EAAS,gBAAgB,CAEzB,EAAS,cAAc,EAIhB,YACX,QAAS,EAAkB,EAAc,EAC1C,CAAC,CAEF,OACE,EAACA,EAAAA,CACC,SAAU,GAAY,GACtB,eAAiB,GAAW,CAC1B,EAAkB,EAAO,CACzB,IAAW,EAAO,CAClB,EAAS,eAAe,EAE1B,MAAO,EACP,aAAc,GAAU,GACxB,SAAU,GAAY,eACtB,MAAO,GAAS,OAChB,GAAI,YAEJ,EAACA,EAAgB,OAAA,CAAA,SAAQ,EAAA,CAAyC,CAClE,EAACA,EAAgB,SAAA,CACf,WAAY,CACV,SAAU,GAAY,UAAY,GAAU,CAC7C,UAED,EAACA,EAAgB,QAAA,CACf,WAAY,CACV,QAAS,GAAY,SAAW,GAAiB,CAClD,CAEA,YACuB,EACD,CAAA,EACX,EAIhBC,GAA4D,CAChE,gBAGE,EAAC,KAAA,CACC,UAAW,GAAY,SAAW,GAAiB,CACnD,mBAAiB,cACjB,CAIN,EAAa,OAASD,EAAgB,OACtC,EAAa,OAAO,YAAc,sBAClC,EAAa,QAAU,EACvB,EAAa,QAAQ,YAAc,uBACnC,EAAa,MAAQA,EAAgB,MACrC,EAAa,MAAM,YAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mage-ui/components",
3
- "version": "0.0.94",
3
+ "version": "0.0.96",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -26,8 +26,8 @@
26
26
  "rimraf": "^6.0.1",
27
27
  "tsdown": "^0.15.6",
28
28
  "typescript": "^5.9.3",
29
- "@mage-ui/preset": "0.0.94",
30
- "@mage-ui/styled-system": "0.0.94"
29
+ "@mage-ui/preset": "0.0.96",
30
+ "@mage-ui/styled-system": "0.0.96"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@hookform/resolvers": "^5.2.2",