UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 2.88 kB
{"version":3,"file":"NativeSelect.cjs","names":["factory","useProps","getParsedComboboxData","NativeSelectOption","InputBase","ComboboxChevron"],"sources":["../../../src/components/NativeSelect/NativeSelect.tsx"],"sourcesContent":["import { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { ComboboxChevron, ComboboxData, getParsedComboboxData } from '../Combobox';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { NativeSelectOption } from './NativeSelectOption';\n\nexport interface NativeSelectProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<NativeSelectFactory>,\n ElementProps<'select', 'size'> {\n /**\n * Data used to render options. Accepts strings, objects with label/value,\n * or grouped options. If `children` prop is provided, `data` will be ignored.\n */\n data?: ComboboxData;\n}\n\nexport type NativeSelectFactory = Factory<{\n props: NativeSelectProps;\n ref: HTMLSelectElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n rightSectionPointerEvents: 'none',\n} satisfies Partial<NativeSelectProps>;\n\nexport const NativeSelect = factory<NativeSelectFactory>((props) => {\n const { data, children, size, error, rightSection, unstyled, ...others } = useProps(\n ['Input', 'InputWrapper', 'NativeSelect'],\n defaultProps,\n props\n );\n\n const options = getParsedComboboxData<string>(data).map((item, index) => (\n <NativeSelectOption key={index} data={item} />\n ));\n\n return (\n <InputBase\n component=\"select\"\n {...others}\n __staticSelector=\"NativeSelect\"\n size={size}\n pointer\n error={error}\n unstyled={unstyled}\n rightSection={\n rightSection || <ComboboxChevron size={size} error={error} unstyled={unstyled} />\n }\n >\n {children || options}\n </InputBase>\n );\n});\n\nNativeSelect.classes = InputBase.classes;\nNativeSelect.displayName = '@mantine/core/NativeSelect';\n\nexport namespace NativeSelect {\n export type Props = NativeSelectProps;\n export type Factory = NativeSelectFactory;\n export type StylesNames = __InputStylesNames;\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,eAAe;CACnB,MAAM;CACN,2BAA2B;AAC7B;AAEA,MAAa,eAAeA,gBAAAA,SAA8B,UAAU;CAClE,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,cAAc,UAAU,GAAG,WAAWC,kBAAAA,SACzE;EAAC;EAAS;EAAgB;CAAc,GACxC,cACA,KACF;CAEA,MAAM,UAAUC,iCAAAA,sBAA8B,IAAI,EAAE,KAAK,MAAM,UAC7D,iBAAA,GAAA,kBAAA,KAACC,2BAAAA,oBAAD,EAAgC,MAAM,KAAO,GAApB,KAAoB,CAC9C;CAED,OACE,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;EACE,WAAU;EACV,GAAI;EACJ,kBAAiB;EACX;EACN,SAAA;EACO;EACG;EACV,cACE,gBAAgB,iBAAA,GAAA,kBAAA,KAACC,wBAAAA,iBAAD;GAAuB;GAAa;GAAiB;EAAW,CAAA;YAGjF,YAAY;CACJ,CAAA;AAEf,CAAC;AAED,aAAa,UAAUD,kBAAAA,UAAU;AACjC,aAAa,cAAc"}