@mantine/core 9.0.0-alpha.6 → 9.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Autocomplete/Autocomplete.cjs +1 -0
- package/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.cjs +1 -0
- package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.cjs.map +1 -1
- package/cjs/components/MultiSelect/MultiSelect.cjs +1 -0
- package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs +2 -0
- package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/cjs/components/Popover/PopoverTarget/PopoverTarget.cjs +2 -2
- package/cjs/components/Popover/PopoverTarget/PopoverTarget.cjs.map +1 -1
- package/cjs/components/Radio/Radio.cjs +1 -1
- package/cjs/components/Radio/Radio.cjs.map +1 -1
- package/cjs/components/Select/Select.cjs +7 -6
- package/cjs/components/Select/Select.cjs.map +1 -1
- package/cjs/components/TagsInput/TagsInput.cjs +1 -0
- package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
- package/esm/components/Autocomplete/Autocomplete.mjs +1 -0
- package/esm/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.mjs +1 -0
- package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.mjs.map +1 -1
- package/esm/components/MultiSelect/MultiSelect.mjs +1 -0
- package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.mjs +2 -0
- package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
- package/esm/components/Popover/PopoverTarget/PopoverTarget.mjs +2 -2
- package/esm/components/Popover/PopoverTarget/PopoverTarget.mjs.map +1 -1
- package/esm/components/Radio/Radio.mjs +1 -1
- package/esm/components/Radio/Radio.mjs.map +1 -1
- package/esm/components/Select/Select.mjs +7 -6
- package/esm/components/Select/Select.mjs.map +1 -1
- package/esm/components/TagsInput/TagsInput.mjs +1 -0
- package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
- package/esm/core/utils/get-env/get-env.mjs +1 -1
- package/esm/core/utils/get-env/get-env.mjs.map +1 -1
- package/lib/components/Combobox/use-combobox-target-props/use-combobox-target-props.d.ts +0 -16
- package/lib/components/Input/InputClearSection/InputClearSection.d.ts +1 -1
- package/lib/components/Input/use-input-props.d.ts +18 -18
- package/lib/components/Popover/use-popover.d.ts +2 -2
- package/lib/core/MantineProvider/color-functions/get-contrast-color/get-contrast-color.d.ts +2 -2
- package/package.json +4 -4
- package/cjs/components/MaskInput/MaskInput.cjs +0 -24
- package/cjs/components/MaskInput/MaskInput.cjs.map +0 -1
- package/cjs/components/MaskInput/use-mask-input-props.cjs +0 -29
- package/cjs/components/MaskInput/use-mask-input-props.cjs.map +0 -1
- package/cjs/components/Pagination/PaginationLabel/PaginationLabel.cjs +0 -33
- package/cjs/components/Pagination/PaginationLabel/PaginationLabel.cjs.map +0 -1
- package/cjs/components/RollingNumber/DigitColumn.cjs +0 -41
- package/cjs/components/RollingNumber/DigitColumn.cjs.map +0 -1
- package/cjs/components/RollingNumber/RollingNumber.cjs +0 -100
- package/cjs/components/RollingNumber/RollingNumber.cjs.map +0 -1
- package/cjs/components/RollingNumber/RollingNumber.module.cjs +0 -12
- package/cjs/components/RollingNumber/RollingNumber.module.cjs.map +0 -1
- package/cjs/components/RollingNumber/build-value.cjs +0 -22
- package/cjs/components/RollingNumber/build-value.cjs.map +0 -1
- package/cjs/components/RollingNumber/get-digit-parts.cjs +0 -40
- package/cjs/components/RollingNumber/get-digit-parts.cjs.map +0 -1
- package/cjs/components/RollingNumber/get-render-slots.cjs +0 -78
- package/cjs/components/RollingNumber/get-render-slots.cjs.map +0 -1
- package/cjs/components/Tree/FlatTreeNode.cjs +0 -102
- package/cjs/components/Tree/FlatTreeNode.cjs.map +0 -1
- package/cjs/components/Tree/filter-tree-data/filter-tree-data.cjs +0 -23
- package/cjs/components/Tree/filter-tree-data/filter-tree-data.cjs.map +0 -1
- package/cjs/components/Tree/flatten-tree-data/flatten-tree-data.cjs +0 -28
- package/cjs/components/Tree/flatten-tree-data/flatten-tree-data.cjs.map +0 -1
- package/cjs/components/Tree/merge-async-children/merge-async-children.cjs +0 -32
- package/cjs/components/Tree/merge-async-children/merge-async-children.cjs.map +0 -1
- package/cjs/components/Tree/move-tree-node/move-tree-node.cjs +0 -78
- package/cjs/components/Tree/move-tree-node/move-tree-node.cjs.map +0 -1
- package/cjs/components/Tree/use-tree-node-drag-drop.cjs +0 -96
- package/cjs/components/Tree/use-tree-node-drag-drop.cjs.map +0 -1
- package/cjs/components/TreeSelect/TreeSelect.cjs +0 -594
- package/cjs/components/TreeSelect/TreeSelect.cjs.map +0 -1
- package/cjs/components/TreeSelect/TreeSelect.module.cjs +0 -16
- package/cjs/components/TreeSelect/TreeSelect.module.cjs.map +0 -1
- package/cjs/components/TreeSelect/TreeSelectOption.cjs +0 -91
- package/cjs/components/TreeSelect/TreeSelectOption.cjs.map +0 -1
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs +0 -34
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs.map +0 -1
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs +0 -30
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs.map +0 -1
- package/esm/components/MaskInput/MaskInput.mjs +0 -23
- package/esm/components/MaskInput/MaskInput.mjs.map +0 -1
- package/esm/components/MaskInput/use-mask-input-props.mjs +0 -28
- package/esm/components/MaskInput/use-mask-input-props.mjs.map +0 -1
- package/esm/components/Pagination/PaginationLabel/PaginationLabel.mjs +0 -32
- package/esm/components/Pagination/PaginationLabel/PaginationLabel.mjs.map +0 -1
- package/esm/components/RollingNumber/DigitColumn.mjs +0 -40
- package/esm/components/RollingNumber/DigitColumn.mjs.map +0 -1
- package/esm/components/RollingNumber/RollingNumber.mjs +0 -99
- package/esm/components/RollingNumber/RollingNumber.mjs.map +0 -1
- package/esm/components/RollingNumber/RollingNumber.module.mjs +0 -12
- package/esm/components/RollingNumber/RollingNumber.module.mjs.map +0 -1
- package/esm/components/RollingNumber/build-value.mjs +0 -22
- package/esm/components/RollingNumber/build-value.mjs.map +0 -1
- package/esm/components/RollingNumber/get-digit-parts.mjs +0 -40
- package/esm/components/RollingNumber/get-digit-parts.mjs.map +0 -1
- package/esm/components/RollingNumber/get-render-slots.mjs +0 -78
- package/esm/components/RollingNumber/get-render-slots.mjs.map +0 -1
- package/esm/components/Tree/FlatTreeNode.mjs +0 -101
- package/esm/components/Tree/FlatTreeNode.mjs.map +0 -1
- package/esm/components/Tree/filter-tree-data/filter-tree-data.mjs +0 -22
- package/esm/components/Tree/filter-tree-data/filter-tree-data.mjs.map +0 -1
- package/esm/components/Tree/flatten-tree-data/flatten-tree-data.mjs +0 -28
- package/esm/components/Tree/flatten-tree-data/flatten-tree-data.mjs.map +0 -1
- package/esm/components/Tree/merge-async-children/merge-async-children.mjs +0 -32
- package/esm/components/Tree/merge-async-children/merge-async-children.mjs.map +0 -1
- package/esm/components/Tree/move-tree-node/move-tree-node.mjs +0 -78
- package/esm/components/Tree/move-tree-node/move-tree-node.mjs.map +0 -1
- package/esm/components/Tree/use-tree-node-drag-drop.mjs +0 -96
- package/esm/components/Tree/use-tree-node-drag-drop.mjs.map +0 -1
- package/esm/components/TreeSelect/TreeSelect.mjs +0 -593
- package/esm/components/TreeSelect/TreeSelect.mjs.map +0 -1
- package/esm/components/TreeSelect/TreeSelect.module.mjs +0 -16
- package/esm/components/TreeSelect/TreeSelect.module.mjs.map +0 -1
- package/esm/components/TreeSelect/TreeSelectOption.mjs +0 -90
- package/esm/components/TreeSelect/TreeSelectOption.mjs.map +0 -1
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs +0 -34
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs.map +0 -1
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs +0 -29
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs.map +0 -1
- package/lib/components/MaskInput/MaskInput.d.ts +0 -68
- package/lib/components/MaskInput/index.d.ts +0 -7
- package/lib/components/MaskInput/use-mask-input-props.d.ts +0 -428
- package/lib/components/Pagination/PaginationLabel/PaginationLabel.d.ts +0 -22
- package/lib/components/RollingNumber/DigitColumn.d.ts +0 -10
- package/lib/components/RollingNumber/RollingNumber.d.ts +0 -39
- package/lib/components/RollingNumber/build-value.d.ts +0 -10
- package/lib/components/RollingNumber/get-digit-parts.d.ts +0 -12
- package/lib/components/RollingNumber/get-render-slots.d.ts +0 -35
- package/lib/components/RollingNumber/index.d.ts +0 -9
- package/lib/components/Tree/FlatTreeNode.d.ts +0 -34
- package/lib/components/Tree/filter-tree-data/filter-tree-data.d.ts +0 -4
- package/lib/components/Tree/flatten-tree-data/flatten-tree-data.d.ts +0 -15
- package/lib/components/Tree/merge-async-children/merge-async-children.d.ts +0 -2
- package/lib/components/Tree/move-tree-node/move-tree-node.d.ts +0 -11
- package/lib/components/Tree/use-tree-node-drag-drop.d.ts +0 -18
- package/lib/components/TreeSelect/TreeSelect.d.ts +0 -122
- package/lib/components/TreeSelect/TreeSelectOption.d.ts +0 -29
- package/lib/components/TreeSelect/flatten-tree-select-data.d.ts +0 -12
- package/lib/components/TreeSelect/get-checked-values-by-strategy.d.ts +0 -4
- package/lib/components/TreeSelect/index.d.ts +0 -13
- package/styles/RollingNumber.css +0 -50
- package/styles/RollingNumber.layer.css +0 -51
- package/styles/TreeSelect.css +0 -113
- package/styles/TreeSelect.layer.css +0 -114
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.mjs","names":["useId"],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\nimport { useId, usePrevious, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n Factory,\n genericFactory,\n MantineColor,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport {\n Combobox,\n ComboboxItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { ScrollAreaProps } from '../ScrollArea';\n\nexport type SelectStylesNames = __InputStylesNames | ComboboxLikeStylesNames;\n\nexport interface SelectProps<Value extends Primitive = string>\n extends\n BoxProps,\n __BaseInputProps,\n ComboboxLikeProps<Value>,\n StylesApiProps<SelectFactory>,\n ElementProps<'input', 'onChange' | 'size' | 'value' | 'defaultValue'> {\n /** Controlled component value */\n value?: Value | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Value | null;\n\n /** Called when value changes */\n onChange?: (value: Value | null, option: ComboboxItem<Value>) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Determines whether the select should be searchable @default false */\n searchable?: boolean;\n\n /** Displays check icon near the selected option label @default true */\n withCheckIcon?: boolean;\n\n /** Aligns unchecked labels with the checked one @default false */\n withAlignedLabels?: boolean;\n\n /** Position of the check icon relative to the option label @default 'left' */\n checkIconPosition?: 'left' | 'right';\n\n /** Message displayed when no options match the search query or when there is no data */\n nothingFoundMessage?: React.ReactNode;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Allows deselecting the selected option by clicking it @default true */\n allowDeselect?: boolean;\n\n /** Displays clear button in the right section when component has value @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** A function to render content of the option, replaces the default content of the option */\n renderOption?: (item: ComboboxLikeRenderOptionInput<ComboboxItem>) => React.ReactNode;\n\n /** Props passed down to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls color of the default chevron, by default depends on the color scheme */\n chevronColor?: MantineColor;\n\n /** Automatically selects the highlighted option when input loses focus @default false */\n autoSelectOnBlur?: boolean;\n\n /** Opens dropdown when input receives focus (requires searchable={true}) @default true */\n openOnFocus?: boolean;\n}\n\nexport type SelectFactory = Factory<{\n props: SelectProps;\n ref: HTMLInputElement;\n stylesNames: SelectStylesNames;\n variant: InputVariant;\n signature: <Value extends Primitive = string>(props: SelectProps<Value>) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n withCheckIcon: true,\n allowDeselect: true,\n checkIconPosition: 'left',\n openOnFocus: true,\n} satisfies Partial<SelectProps>;\n\nexport const Select = genericFactory<SelectFactory>((_props) => {\n const props = useProps('Select', defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n vars,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownClose,\n onDropdownOpen,\n onFocus,\n onBlur,\n onClick,\n onChange,\n data,\n value,\n defaultValue,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n readOnly,\n disabled,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n size,\n searchable,\n rightSection,\n checkIconPosition,\n withCheckIcon,\n withAlignedLabels,\n nothingFoundMessage,\n name,\n form,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n allowDeselect,\n error,\n rightSectionPointerEvents,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n renderOption,\n onClear,\n autoComplete,\n scrollAreaProps,\n __defaultRightSection,\n __clearSection,\n __clearable,\n chevronColor,\n autoSelectOnBlur,\n openOnFocus,\n attributes,\n ...others\n } = props;\n\n const parsedData = useMemo(() => getParsedComboboxData(data), [data]);\n const retainedSelectedOptions = useRef<Record<string, ComboboxItem<Primitive>>>({});\n const optionsLockup = useMemo(() => getOptionsLockup(parsedData), [parsedData]);\n const _id = useId(id);\n\n const [_value, setValue, controlled] = useUncontrolled({\n value,\n defaultValue,\n finalValue: null,\n onChange,\n });\n\n const selectedOption =\n typeof _value === 'string'\n ? _value in optionsLockup\n ? optionsLockup[_value]\n : retainedSelectedOptions.current[_value]\n : undefined;\n const previousSelectedOption = usePrevious(selectedOption);\n\n const [search, setSearch, searchControlled] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: selectedOption ? selectedOption.label : '',\n onChange: onSearchChange,\n });\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n if (selectFirstOptionOnDropdownOpen) {\n combobox.selectFirstOption();\n } else {\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n }\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n // Required for autoSelectOnBlur to work correctly\n setTimeout(combobox.resetSelectedOption, 0);\n },\n });\n\n const handleSearchChange = (value: string) => {\n setSearch(value);\n combobox.resetSelectedOption();\n };\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<SelectFactory>({\n props,\n styles,\n classNames,\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, search]);\n\n useEffect(() => {\n if (value === null) {\n handleSearchChange('');\n }\n\n if (\n typeof value === 'string' &&\n selectedOption &&\n (previousSelectedOption?.value !== selectedOption.value ||\n previousSelectedOption?.label !== selectedOption.label)\n ) {\n handleSearchChange(selectedOption.label);\n }\n }, [value, selectedOption]);\n\n useEffect(() => {\n if (!controlled && !searchControlled) {\n handleSearchChange(\n typeof _value === 'string'\n ? _value in optionsLockup\n ? optionsLockup[_value]?.label\n : retainedSelectedOptions.current[_value]?.label || ''\n : ''\n );\n }\n }, [optionsLockup, _value]);\n\n useEffect(() => {\n if (_value) {\n if (`${_value}` in optionsLockup) {\n retainedSelectedOptions.current[`${_value}`] = optionsLockup[`${_value}`];\n }\n }\n }, [optionsLockup, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n setValue(null, null);\n handleSearchChange('');\n onClear?.();\n }}\n />\n );\n\n const _clearable = clearable && !!_value && !disabled && !readOnly;\n\n return (\n <>\n <Combobox\n store={combobox}\n __staticSelector=\"Select\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n keepMounted={autoSelectOnBlur}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val as any);\n const optionLockup = allowDeselect\n ? optionsLockup[val].value === _value\n ? null\n : optionsLockup[val]\n : optionsLockup[val];\n\n const nextValue = optionLockup ? optionLockup.value : null;\n\n nextValue !== _value && setValue(nextValue as any, optionLockup);\n !controlled &&\n handleSearchChange(typeof nextValue === 'string' ? optionLockup?.label || '' : '');\n combobox.closeDropdown();\n }}\n {...comboboxProps}\n >\n <Combobox.Target targetType={searchable ? 'input' : 'button'} autoComplete={autoComplete}>\n <InputBase\n id={_id}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n {...others}\n size={size}\n __staticSelector=\"Select\"\n disabled={disabled}\n readOnly={readOnly || !searchable}\n value={search}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n onFocus={(event) => {\n openOnFocus && !!searchable && combobox.openDropdown();\n onFocus?.(event);\n }}\n onBlur={(event) => {\n if (autoSelectOnBlur) {\n combobox.clickSelectedOption();\n }\n\n !!searchable && combobox.closeDropdown();\n const optionLockup =\n typeof _value === 'string' &&\n (_value in optionsLockup\n ? optionsLockup[_value]\n : retainedSelectedOptions.current[_value]);\n handleSearchChange(optionLockup ? optionLockup.label || '' : '');\n onBlur?.(event);\n }}\n onClick={(event) => {\n searchable ? combobox.openDropdown() : combobox.toggleDropdown();\n onClick?.(event);\n }}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n pointer={!searchable}\n error={error}\n attributes={attributes}\n />\n </Combobox.Target>\n <OptionsDropdown\n data={parsedData as any}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={search}\n limit={limit}\n hiddenWhenEmpty={!nothingFoundMessage}\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n filterOptions={!!searchable && selectedOption?.label !== search}\n value={_value}\n checkIconPosition={checkIconPosition}\n withCheckIcon={withCheckIcon}\n withAlignedLabels={withAlignedLabels}\n nothingFoundMessage={nothingFoundMessage}\n unstyled={unstyled}\n labelId={others.label ? `${_id}-label` : undefined}\n aria-label={others.label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n <Combobox.HiddenInput\n value={_value}\n name={name}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nSelect.displayName = '@mantine/core/Select';\n"],"mappings":";;;;;;;;;;;;;;AAuHA,MAAM,eAAe;CACnB,eAAe;CACf,eAAe;CACf,mBAAmB;CACnB,aAAa;CACd;AAED,MAAa,SAAS,gBAA+B,WAAW;CAC9D,MAAM,QAAQ,SAAS,UAAU,cAAc,OAAO;CACtD,MAAM,EACJ,YACA,QACA,UACA,MACA,gBACA,uBACA,iBACA,gBACA,SACA,QACA,SACA,UACA,MACA,OACA,cACA,2BACA,iC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../../../src/components/Select/Select.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\nimport { useId, usePrevious, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n Factory,\n genericFactory,\n MantineColor,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport {\n Combobox,\n ComboboxItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { ScrollAreaProps } from '../ScrollArea';\n\nexport type SelectStylesNames = __InputStylesNames | ComboboxLikeStylesNames;\n\nexport interface SelectProps<Value extends Primitive = string>\n extends\n BoxProps,\n __BaseInputProps,\n ComboboxLikeProps<Value>,\n StylesApiProps<SelectFactory>,\n ElementProps<'input', 'onChange' | 'size' | 'value' | 'defaultValue'> {\n /** Controlled component value */\n value?: Value | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Value | null;\n\n /** Called when value changes */\n onChange?: (value: Value | null, option: ComboboxItem<Value>) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Determines whether the select should be searchable @default false */\n searchable?: boolean;\n\n /** Displays check icon near the selected option label @default true */\n withCheckIcon?: boolean;\n\n /** Aligns unchecked labels with the checked one @default false */\n withAlignedLabels?: boolean;\n\n /** Position of the check icon relative to the option label @default 'left' */\n checkIconPosition?: 'left' | 'right';\n\n /** Message displayed when no options match the search query or when there is no data */\n nothingFoundMessage?: React.ReactNode;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Allows deselecting the selected option by clicking it @default true */\n allowDeselect?: boolean;\n\n /** Displays clear button in the right section when component has value @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** A function to render content of the option, replaces the default content of the option */\n renderOption?: (item: ComboboxLikeRenderOptionInput<ComboboxItem>) => React.ReactNode;\n\n /** Props passed down to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls color of the default chevron, by default depends on the color scheme */\n chevronColor?: MantineColor;\n\n /** Automatically selects the highlighted option when input loses focus @default false */\n autoSelectOnBlur?: boolean;\n\n /** Opens dropdown when input receives focus (requires searchable={true}) @default true */\n openOnFocus?: boolean;\n}\n\nexport type SelectFactory = Factory<{\n props: SelectProps;\n ref: HTMLInputElement;\n stylesNames: SelectStylesNames;\n variant: InputVariant;\n signature: <Value extends Primitive = string>(props: SelectProps<Value>) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n withCheckIcon: true,\n allowDeselect: true,\n checkIconPosition: 'left',\n openOnFocus: true,\n} satisfies Partial<SelectProps>;\n\nexport const Select = genericFactory<SelectFactory>((_props) => {\n const props = useProps('Select', defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n vars,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownClose,\n onDropdownOpen,\n onFocus,\n onBlur,\n onClick,\n onChange,\n data,\n value,\n defaultValue,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n readOnly,\n disabled,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n size,\n searchable,\n rightSection,\n checkIconPosition,\n withCheckIcon,\n withAlignedLabels,\n nothingFoundMessage,\n name,\n form,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n allowDeselect,\n error,\n rightSectionPointerEvents,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n renderOption,\n onClear,\n autoComplete,\n scrollAreaProps,\n __defaultRightSection,\n __clearSection,\n __clearable,\n chevronColor,\n autoSelectOnBlur,\n openOnFocus,\n attributes,\n ...others\n } = props;\n\n const parsedData = useMemo(() => getParsedComboboxData(data), [data]);\n const retainedSelectedOptions = useRef<Record<string, ComboboxItem<Primitive>>>({});\n const optionsLockup = useMemo(() => getOptionsLockup(parsedData), [parsedData]);\n const _id = useId(id);\n\n const [_value, setValue, controlled] = useUncontrolled({\n value,\n defaultValue,\n finalValue: null,\n onChange,\n });\n\n const selectedOption =\n _value != null\n ? `${_value}` in optionsLockup\n ? optionsLockup[`${_value}`]\n : retainedSelectedOptions.current[`${_value}`]\n : undefined;\n const previousSelectedOption = usePrevious(selectedOption);\n\n const [search, setSearch, searchControlled] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: selectedOption ? selectedOption.label : '',\n onChange: onSearchChange,\n });\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n if (selectFirstOptionOnDropdownOpen) {\n combobox.selectFirstOption();\n } else {\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n }\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n // Required for autoSelectOnBlur to work correctly\n setTimeout(combobox.resetSelectedOption, 0);\n },\n });\n\n const handleSearchChange = (value: string) => {\n setSearch(value);\n combobox.resetSelectedOption();\n };\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<SelectFactory>({\n props,\n styles,\n classNames,\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, search]);\n\n useEffect(() => {\n if (value === null) {\n handleSearchChange('');\n }\n\n if (\n value != null &&\n selectedOption &&\n (previousSelectedOption?.value !== selectedOption.value ||\n previousSelectedOption?.label !== selectedOption.label)\n ) {\n handleSearchChange(selectedOption.label);\n }\n }, [value, selectedOption]);\n\n useEffect(() => {\n if (!controlled && !searchControlled) {\n handleSearchChange(\n _value != null\n ? `${_value}` in optionsLockup\n ? optionsLockup[`${_value}`]?.label\n : retainedSelectedOptions.current[`${_value}`]?.label || ''\n : ''\n );\n }\n }, [optionsLockup, _value]);\n\n useEffect(() => {\n if (_value) {\n if (`${_value}` in optionsLockup) {\n retainedSelectedOptions.current[`${_value}`] = optionsLockup[`${_value}`];\n }\n }\n }, [optionsLockup, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n setValue(null, null);\n handleSearchChange('');\n onClear?.();\n }}\n />\n );\n\n const _clearable = clearable && !!_value && !disabled && !readOnly;\n\n return (\n <>\n <Combobox\n store={combobox}\n __staticSelector=\"Select\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n keepMounted={autoSelectOnBlur}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val as any);\n const optionLockup = allowDeselect\n ? `${optionsLockup[val].value}` === `${_value}`\n ? null\n : optionsLockup[val]\n : optionsLockup[val];\n\n const nextValue = optionLockup ? optionLockup.value : null;\n\n nextValue !== _value && setValue(nextValue as any, optionLockup);\n !controlled && handleSearchChange(nextValue != null ? optionLockup?.label || '' : '');\n combobox.closeDropdown();\n }}\n {...comboboxProps}\n >\n <Combobox.Target\n targetType={searchable ? 'input' : 'button'}\n autoComplete={autoComplete}\n withExpandedAttribute\n >\n <InputBase\n id={_id}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n {...others}\n size={size}\n __staticSelector=\"Select\"\n disabled={disabled}\n readOnly={readOnly || !searchable}\n value={search}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n onFocus={(event) => {\n openOnFocus && !!searchable && combobox.openDropdown();\n onFocus?.(event);\n }}\n onBlur={(event) => {\n if (autoSelectOnBlur) {\n combobox.clickSelectedOption();\n }\n\n !!searchable && combobox.closeDropdown();\n const optionLockup =\n _value != null &&\n (`${_value}` in optionsLockup\n ? optionsLockup[`${_value}`]\n : retainedSelectedOptions.current[`${_value}`]);\n handleSearchChange(optionLockup ? optionLockup.label || '' : '');\n onBlur?.(event);\n }}\n onClick={(event) => {\n searchable ? combobox.openDropdown() : combobox.toggleDropdown();\n onClick?.(event);\n }}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n pointer={!searchable}\n error={error}\n attributes={attributes}\n />\n </Combobox.Target>\n <OptionsDropdown\n data={parsedData as any}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={search}\n limit={limit}\n hiddenWhenEmpty={!nothingFoundMessage}\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n filterOptions={!!searchable && selectedOption?.label !== search}\n value={_value}\n checkIconPosition={checkIconPosition}\n withCheckIcon={withCheckIcon}\n withAlignedLabels={withAlignedLabels}\n nothingFoundMessage={nothingFoundMessage}\n unstyled={unstyled}\n labelId={others.label ? `${_id}-label` : undefined}\n aria-label={others.label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n <Combobox.HiddenInput\n value={_value}\n name={name}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nSelect.displayName = '@mantine/core/Select';\n"],"mappings":";;;;;;;;;;;;;;AAuHA,MAAM,eAAe;CACnB,eAAe;CACf,eAAe;CACf,mBAAmB;CACnB,aAAa;CACd;AAED,MAAa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AC,SAAS,aAAV;EACE,OAAO;EACD;EACA;EACI;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,OAAO,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AAC9D,OAAO,cAAc"}
|
|
@@ -245,6 +245,7 @@ const TagsInput = factory((_props) => {
|
|
|
245
245
|
...getStyles("pillsList"),
|
|
246
246
|
children: [values, /* @__PURE__ */ jsx(Combobox.EventsTarget, {
|
|
247
247
|
autoComplete,
|
|
248
|
+
withExpandedAttribute: true,
|
|
248
249
|
children: /* @__PURE__ */ jsx(PillsInput.Field, {
|
|
249
250
|
...rest,
|
|
250
251
|
ref: _ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagsInput.mjs","names":["useId"],"sources":["../../../src/components/TagsInput/TagsInput.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef } from 'react';\nimport { useId, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n Combobox,\n ComboboxGenericData,\n ComboboxGenericItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n ComboboxRenderPillInput,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Pill } from '../Pill';\nimport { PillsInput } from '../PillsInput';\nimport { ScrollAreaProps } from '../ScrollArea';\nimport { filterPickedTags } from './filter-picked-tags';\nimport { getSplittedTags } from './get-splitted-tags';\n\nexport type TagsInputStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport interface TagsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n Omit<ComboboxLikeProps, 'data'>,\n StylesApiProps<TagsInputFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Data displayed in the dropdown. Values must be unique. */\n data?: ComboboxGenericData;\n\n /** Controlled component value */\n value?: string[];\n\n /** Uncontrolled component default value */\n defaultValue?: string[];\n\n /** Called when value changes */\n onChange?: (value: string[]) => void;\n\n /** Called when tag is removed */\n onRemove?: (value: string) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Maximum number of tags @default Infinity */\n maxTags?: number;\n\n /** Called when user tries to add more tags than maxTags */\n onMaxTags?: (value: string) => void;\n\n /** If set, duplicate tags are allowed @default false */\n allowDuplicates?: boolean;\n\n /** Called when user tries to submit a duplicated tag */\n onDuplicate?: (value: string) => void;\n\n /** Characters that should trigger tags split, `[',']` by default */\n splitChars?: string[];\n\n /** If set, the clear button is displayed in the right section when the component has value @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Divider used to separate values in the hidden input `value` attribute @default ',' */\n hiddenInputValuesDivider?: string;\n\n /** A function to render content of the option, replaces the default content of the option */\n renderOption?: (input: ComboboxLikeRenderOptionInput<ComboboxGenericItem>) => React.ReactNode;\n\n /** A function to render content of the pill, replaces the default content of the pill */\n renderPill?: (props: ComboboxRenderPillInput) => React.ReactNode;\n\n /** Props passed down to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** If set, the value typed in by the user but not submitted is accepted when the input is blurred @default true */\n acceptValueOnBlur?: boolean;\n\n /** Custom function to determine if a tag is duplicate. Accepts tag value and array of current values. By default, checks if the tag exists case-insensitively. */\n isDuplicate?: (value: string, currentValues: string[]) => boolean;\n\n /** If set, the dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n}\n\nexport type TagsInputFactory = Factory<{\n props: TagsInputProps;\n ref: HTMLInputElement;\n stylesNames: TagsInputStylesNames;\n}>;\n\nconst defaultProps = {\n maxTags: Infinity,\n acceptValueOnBlur: true,\n splitChars: [','],\n hiddenInputValuesDivider: ',',\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<TagsInputProps>;\n\nexport const TagsInput = factory<TagsInputFactory>((_props) => {\n const props = useProps('TagsInput', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n value,\n defaultValue,\n onChange,\n onKeyDown,\n maxTags,\n allowDuplicates,\n onDuplicate,\n variant,\n data,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n readOnly,\n disabled,\n splitChars,\n onFocus,\n onBlur,\n onPaste,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n required,\n labelProps,\n descriptionProps,\n errorProps,\n wrapperProps,\n description,\n label,\n error,\n withErrorStyles,\n name,\n form,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n hiddenInputValuesDivider,\n mod,\n renderOption,\n renderPill,\n onRemove,\n onClear,\n onMaxTags,\n scrollAreaProps,\n acceptValueOnBlur,\n isDuplicate,\n openOnFocus,\n attributes,\n ref,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n const inputRef = useRef<HTMLInputElement>(null);\n const _ref = useMergedRef(inputRef, ref);\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n if (selectFirstOptionOnDropdownOpen) {\n combobox.selectFirstOption();\n }\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: [],\n onChange,\n });\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: '',\n onChange: onSearchChange,\n });\n\n const handleSearchChange = (value: string) => {\n setSearchValue(value);\n combobox.resetSelectedOption();\n };\n\n const getStyles = useStyles<TagsInputFactory>({\n name: 'TagsInput',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<TagsInputFactory>({\n props,\n styles,\n classNames,\n });\n\n const handleValueSelect = (val: string) => {\n const isDuplicated = isDuplicate\n ? isDuplicate(val, _value)\n : _value.some((tag) => tag.toLowerCase() === val.toLowerCase());\n\n if (isDuplicated) {\n onDuplicate?.(val);\n if (!allowDuplicates) {\n handleSearchChange('');\n return;\n }\n }\n\n if (_value.length >= maxTags) {\n onMaxTags?.(val);\n return;\n }\n\n onOptionSubmit?.(val);\n handleSearchChange('');\n if (val.length > 0) {\n setValue([..._value, val]);\n }\n };\n\n const handleInputKeydown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.isPropagationStopped()) {\n return;\n }\n\n const inputValue = _searchValue.trim();\n const { length } = inputValue;\n\n if (splitChars.includes(event.key) && length > 0) {\n setValue(\n getSplittedTags({\n splitChars,\n allowDuplicates,\n maxTags,\n value: _searchValue,\n currentTags: _value,\n isDuplicate,\n onDuplicate,\n })\n );\n handleSearchChange('');\n event.preventDefault();\n }\n\n if (event.key === 'Enter' && length > 0 && !event.nativeEvent.isComposing) {\n event.preventDefault();\n\n const hasActiveSelection = !!document.querySelector<HTMLDivElement>(\n `#${combobox.listId} [data-combobox-option][data-combobox-selected]`\n );\n\n if (hasActiveSelection) {\n return;\n }\n\n handleValueSelect(inputValue);\n }\n\n if (\n event.key === 'Backspace' &&\n length === 0 &&\n _value.length > 0 &&\n !event.nativeEvent.isComposing &&\n !readOnly\n ) {\n onRemove?.(_value[_value.length - 1]);\n setValue(_value.slice(0, _value.length - 1));\n }\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event);\n event.preventDefault();\n\n if (event.clipboardData) {\n const pastedText = event.clipboardData.getData('text/plain');\n setValue(\n getSplittedTags({\n splitChars,\n allowDuplicates,\n maxTags,\n value: `${_searchValue}${pastedText}`,\n currentTags: _value,\n isDuplicate,\n onDuplicate,\n })\n );\n handleSearchChange('');\n }\n };\n\n const values = _value.map((item, index) => {\n const onRemoveItem = () => {\n const next_value = _value.slice();\n next_value.splice(index, 1);\n setValue(next_value);\n onRemove?.(item);\n };\n\n if (renderPill) {\n return (\n <Fragment key={`${item}-${index}`}>\n {renderPill({\n option: optionsLockup[item] || { value: item, label: item, disabled: false },\n value: item,\n onRemove: onRemoveItem,\n disabled: disabled || readOnly,\n })}\n </Fragment>\n );\n }\n\n return (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly}\n onRemove={onRemoveItem}\n unstyled={unstyled}\n disabled={disabled}\n attributes={attributes}\n {...getStyles('pill')}\n >\n {item}\n </Pill>\n );\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _value, _searchValue]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n setValue([]);\n handleSearchChange('');\n inputRef.current?.focus();\n combobox.openDropdown();\n onClear?.();\n }}\n />\n );\n\n return (\n <>\n <Combobox\n store={combobox}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n readOnly={readOnly}\n __staticSelector=\"TagsInput\"\n attributes={attributes}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val);\n handleSearchChange('');\n\n if (_value.length >= maxTags) {\n onMaxTags?.(val);\n } else {\n setValue([..._value, optionsLockup[val].value]);\n }\n\n combobox.resetSelectedOption();\n }}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"TagsInput\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n className={className}\n style={style}\n variant={variant}\n disabled={disabled}\n radius={radius}\n rightSection={rightSection}\n __clearSection={clearButton}\n __clearable={clearable && _value.length > 0 && !disabled && !readOnly}\n __clearSectionMode={clearSectionMode}\n rightSectionWidth={rightSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n required={required}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n error={error}\n withErrorStyles={withErrorStyles}\n __stylesApiProps={{ ...props, multiline: true }}\n id={_id}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group disabled={disabled} unstyled={unstyled} {...getStyles('pillsList')}>\n {values}\n <Combobox.EventsTarget autoComplete={autoComplete}>\n <PillsInput.Field\n {...rest}\n ref={_ref}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onKeyDown={handleInputKeydown}\n onFocus={(event) => {\n onFocus?.(event);\n openOnFocus && combobox.openDropdown();\n }}\n onBlur={(event) => {\n onBlur?.(event);\n acceptValueOnBlur && handleValueSelect(_searchValue);\n combobox.closeDropdown();\n }}\n onPaste={handlePaste}\n value={_searchValue}\n onChange={(event) => handleSearchChange(event.currentTarget.value)}\n required={required && _value.length === 0}\n disabled={disabled}\n readOnly={readOnly}\n id={_id}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n\n <OptionsDropdown\n data={filterPickedTags({ data: parsedData, value: _value })}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_searchValue}\n limit={limit}\n hiddenWhenEmpty\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n unstyled={unstyled}\n labelId={label ? `${_id}-label` : undefined}\n aria-label={label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n <Combobox.HiddenInput\n name={name}\n form={form}\n value={_value}\n valuesDivider={hiddenInputValuesDivider}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nTagsInput.classes = { ...InputBase.classes, ...Combobox.classes };\nTagsInput.displayName = '@mantine/core/TagsInput';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyIA,MAAM,eAAe;CACnB,SAAS;CACT,mBAAmB;CACnB,YAAY,CAAC,IAAI;CACjB,0BAA0B;CAC1B,aAAa;CACb,MAAM;CACP;AAED,MAAa,YAAY,SAA2B,WAAW;CAC7D,MAAM,QAAQ,SAAS,aAAa,cAAc,OAAO;CACzD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,OACA,cACA,UACA,WACA,SACA,iBACA,aACA,SACA,MACA,gBACA,uBACA,gBACA,iBACA,2BACA,iCACA,gBACA,eACA,QACA,OACA,gBACA,mBACA,aACA,oBACA,gBACA,UACA,UACA,YACA,SACA,QACA,SACA,QACA,cACA,mBACA,2BACA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J;GACE;GACM;GACN;GACE;GACD;GACN;GACA;GACU;GACjB,kBAAkB;IAAE,GAAG;IAAO,WAAW;IAAM;GAC/C,IAAI;GACC;GACO;aAEZ,qBAAC,KAAK,OAAN;IAAsB;IAAoB;IAAU,GAAI,UAAU,YAAY;cAA9E,CACG,QACD,oBAAC,SAAS,cAAV;KAAqC;eACnC,oBAAC,WAAW,OAAZ;MACE,GAAI;MACJ,KAAK;MACL,GAAI,UAAU,aAAa;MACjB;MACV,WAAW;MACX,UAAU,UAAU;AAClB,iBAAU,MAAM;AAChB,sBAAe,SAAS,cAAc;;MAExC,SAAS,UAAU;AACjB,gBAAS,MAAM;AACf,4BAAqB,kBAAkB,aAAa;AACpD,gBAAS,eAAe;;MAE1B,SAAS;MACT,OAAO;MACP,WAAW,UAAU,mBAAmB,MAAM,cAAc,MAAM;MAClE,UAAU,YAAY,OAAO,WAAW;MAC9B;MACA;MACV,IAAI;MACJ,CAAA;KACoB,CAAA,CACb;;GACF,CAAA,EACW,CAAA,EAE1B,oBAAC,iBAAD;GACE,MAAM,iBAAiB;IAAE,MAAM;IAAY,OAAO;IAAQ,CAAC;GAC3D,QAAQ,YAAY;GACZ;GACR,QAAQ;GACD;GACP,iBAAA;GACgB;GACG;GACT;GACV,SAAS,QAAQ,GAAG,IAAI,UAAU,KAAA;GAClC,cAAY,QAAQ,KAAA,IAAY,OAAO;GACzB;GACG;GACjB,CAAA,CACO;KACX,oBAAC,SAAS,aAAV;EACQ;EACA;EACN,OAAO;EACP,eAAe;EACL;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,UAAU,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AACjE,UAAU,cAAc"}
|
|
1
|
+
{"version":3,"file":"TagsInput.mjs","names":["useId"],"sources":["../../../src/components/TagsInput/TagsInput.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef } from 'react';\nimport { useId, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n Combobox,\n ComboboxGenericData,\n ComboboxGenericItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n ComboboxRenderPillInput,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Pill } from '../Pill';\nimport { PillsInput } from '../PillsInput';\nimport { ScrollAreaProps } from '../ScrollArea';\nimport { filterPickedTags } from './filter-picked-tags';\nimport { getSplittedTags } from './get-splitted-tags';\n\nexport type TagsInputStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport interface TagsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n Omit<ComboboxLikeProps, 'data'>,\n StylesApiProps<TagsInputFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Data displayed in the dropdown. Values must be unique. */\n data?: ComboboxGenericData;\n\n /** Controlled component value */\n value?: string[];\n\n /** Uncontrolled component default value */\n defaultValue?: string[];\n\n /** Called when value changes */\n onChange?: (value: string[]) => void;\n\n /** Called when tag is removed */\n onRemove?: (value: string) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Maximum number of tags @default Infinity */\n maxTags?: number;\n\n /** Called when user tries to add more tags than maxTags */\n onMaxTags?: (value: string) => void;\n\n /** If set, duplicate tags are allowed @default false */\n allowDuplicates?: boolean;\n\n /** Called when user tries to submit a duplicated tag */\n onDuplicate?: (value: string) => void;\n\n /** Characters that should trigger tags split, `[',']` by default */\n splitChars?: string[];\n\n /** If set, the clear button is displayed in the right section when the component has value @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Divider used to separate values in the hidden input `value` attribute @default ',' */\n hiddenInputValuesDivider?: string;\n\n /** A function to render content of the option, replaces the default content of the option */\n renderOption?: (input: ComboboxLikeRenderOptionInput<ComboboxGenericItem>) => React.ReactNode;\n\n /** A function to render content of the pill, replaces the default content of the pill */\n renderPill?: (props: ComboboxRenderPillInput) => React.ReactNode;\n\n /** Props passed down to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** If set, the value typed in by the user but not submitted is accepted when the input is blurred @default true */\n acceptValueOnBlur?: boolean;\n\n /** Custom function to determine if a tag is duplicate. Accepts tag value and array of current values. By default, checks if the tag exists case-insensitively. */\n isDuplicate?: (value: string, currentValues: string[]) => boolean;\n\n /** If set, the dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n}\n\nexport type TagsInputFactory = Factory<{\n props: TagsInputProps;\n ref: HTMLInputElement;\n stylesNames: TagsInputStylesNames;\n}>;\n\nconst defaultProps = {\n maxTags: Infinity,\n acceptValueOnBlur: true,\n splitChars: [','],\n hiddenInputValuesDivider: ',',\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<TagsInputProps>;\n\nexport const TagsInput = factory<TagsInputFactory>((_props) => {\n const props = useProps('TagsInput', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n value,\n defaultValue,\n onChange,\n onKeyDown,\n maxTags,\n allowDuplicates,\n onDuplicate,\n variant,\n data,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n readOnly,\n disabled,\n splitChars,\n onFocus,\n onBlur,\n onPaste,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n required,\n labelProps,\n descriptionProps,\n errorProps,\n wrapperProps,\n description,\n label,\n error,\n withErrorStyles,\n name,\n form,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n hiddenInputValuesDivider,\n mod,\n renderOption,\n renderPill,\n onRemove,\n onClear,\n onMaxTags,\n scrollAreaProps,\n acceptValueOnBlur,\n isDuplicate,\n openOnFocus,\n attributes,\n ref,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n const inputRef = useRef<HTMLInputElement>(null);\n const _ref = useMergedRef(inputRef, ref);\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n if (selectFirstOptionOnDropdownOpen) {\n combobox.selectFirstOption();\n }\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: [],\n onChange,\n });\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: '',\n onChange: onSearchChange,\n });\n\n const handleSearchChange = (value: string) => {\n setSearchValue(value);\n combobox.resetSelectedOption();\n };\n\n const getStyles = useStyles<TagsInputFactory>({\n name: 'TagsInput',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<TagsInputFactory>({\n props,\n styles,\n classNames,\n });\n\n const handleValueSelect = (val: string) => {\n const isDuplicated = isDuplicate\n ? isDuplicate(val, _value)\n : _value.some((tag) => tag.toLowerCase() === val.toLowerCase());\n\n if (isDuplicated) {\n onDuplicate?.(val);\n if (!allowDuplicates) {\n handleSearchChange('');\n return;\n }\n }\n\n if (_value.length >= maxTags) {\n onMaxTags?.(val);\n return;\n }\n\n onOptionSubmit?.(val);\n handleSearchChange('');\n if (val.length > 0) {\n setValue([..._value, val]);\n }\n };\n\n const handleInputKeydown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.isPropagationStopped()) {\n return;\n }\n\n const inputValue = _searchValue.trim();\n const { length } = inputValue;\n\n if (splitChars.includes(event.key) && length > 0) {\n setValue(\n getSplittedTags({\n splitChars,\n allowDuplicates,\n maxTags,\n value: _searchValue,\n currentTags: _value,\n isDuplicate,\n onDuplicate,\n })\n );\n handleSearchChange('');\n event.preventDefault();\n }\n\n if (event.key === 'Enter' && length > 0 && !event.nativeEvent.isComposing) {\n event.preventDefault();\n\n const hasActiveSelection = !!document.querySelector<HTMLDivElement>(\n `#${combobox.listId} [data-combobox-option][data-combobox-selected]`\n );\n\n if (hasActiveSelection) {\n return;\n }\n\n handleValueSelect(inputValue);\n }\n\n if (\n event.key === 'Backspace' &&\n length === 0 &&\n _value.length > 0 &&\n !event.nativeEvent.isComposing &&\n !readOnly\n ) {\n onRemove?.(_value[_value.length - 1]);\n setValue(_value.slice(0, _value.length - 1));\n }\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event);\n event.preventDefault();\n\n if (event.clipboardData) {\n const pastedText = event.clipboardData.getData('text/plain');\n setValue(\n getSplittedTags({\n splitChars,\n allowDuplicates,\n maxTags,\n value: `${_searchValue}${pastedText}`,\n currentTags: _value,\n isDuplicate,\n onDuplicate,\n })\n );\n handleSearchChange('');\n }\n };\n\n const values = _value.map((item, index) => {\n const onRemoveItem = () => {\n const next_value = _value.slice();\n next_value.splice(index, 1);\n setValue(next_value);\n onRemove?.(item);\n };\n\n if (renderPill) {\n return (\n <Fragment key={`${item}-${index}`}>\n {renderPill({\n option: optionsLockup[item] || { value: item, label: item, disabled: false },\n value: item,\n onRemove: onRemoveItem,\n disabled: disabled || readOnly,\n })}\n </Fragment>\n );\n }\n\n return (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly}\n onRemove={onRemoveItem}\n unstyled={unstyled}\n disabled={disabled}\n attributes={attributes}\n {...getStyles('pill')}\n >\n {item}\n </Pill>\n );\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _value, _searchValue]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n setValue([]);\n handleSearchChange('');\n inputRef.current?.focus();\n combobox.openDropdown();\n onClear?.();\n }}\n />\n );\n\n return (\n <>\n <Combobox\n store={combobox}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n readOnly={readOnly}\n __staticSelector=\"TagsInput\"\n attributes={attributes}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val);\n handleSearchChange('');\n\n if (_value.length >= maxTags) {\n onMaxTags?.(val);\n } else {\n setValue([..._value, optionsLockup[val].value]);\n }\n\n combobox.resetSelectedOption();\n }}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"TagsInput\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n className={className}\n style={style}\n variant={variant}\n disabled={disabled}\n radius={radius}\n rightSection={rightSection}\n __clearSection={clearButton}\n __clearable={clearable && _value.length > 0 && !disabled && !readOnly}\n __clearSectionMode={clearSectionMode}\n rightSectionWidth={rightSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n required={required}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n error={error}\n withErrorStyles={withErrorStyles}\n __stylesApiProps={{ ...props, multiline: true }}\n id={_id}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group disabled={disabled} unstyled={unstyled} {...getStyles('pillsList')}>\n {values}\n <Combobox.EventsTarget autoComplete={autoComplete} withExpandedAttribute>\n <PillsInput.Field\n {...rest}\n ref={_ref}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onKeyDown={handleInputKeydown}\n onFocus={(event) => {\n onFocus?.(event);\n openOnFocus && combobox.openDropdown();\n }}\n onBlur={(event) => {\n onBlur?.(event);\n acceptValueOnBlur && handleValueSelect(_searchValue);\n combobox.closeDropdown();\n }}\n onPaste={handlePaste}\n value={_searchValue}\n onChange={(event) => handleSearchChange(event.currentTarget.value)}\n required={required && _value.length === 0}\n disabled={disabled}\n readOnly={readOnly}\n id={_id}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n\n <OptionsDropdown\n data={filterPickedTags({ data: parsedData, value: _value })}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_searchValue}\n limit={limit}\n hiddenWhenEmpty\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n unstyled={unstyled}\n labelId={label ? `${_id}-label` : undefined}\n aria-label={label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n <Combobox.HiddenInput\n name={name}\n form={form}\n value={_value}\n valuesDivider={hiddenInputValuesDivider}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nTagsInput.classes = { ...InputBase.classes, ...Combobox.classes };\nTagsInput.displayName = '@mantine/core/TagsInput';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyIA,MAAM,eAAe;CACnB,SAAS;CACT,mBAAmB;CACnB,YAAY,CAAC,IAAI;CACjB,0BAA0B;CAC1B,aAAa;CACb,MAAM;CACP;AAED,MAAa,YAAY,SAA2B,WAAW;CAC7D,MAAM,QAAQ,SAAS,aAAa,cAAc,OAAO;CACzD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,OACA,cACA,UACA,WACA,SACA,iBACA,aACA,SACA,MACA,gBACA,uBACA,gBACA,iBACA,2BACA,iCACA,gBACA,eACA,QACA,OACA,gBACA,mBACA,aACA,oBACA,gBACA,UACA,UACA,YACA,SACA,QACA,SACA,QACA,cACA,mBACA,2BACA,mBACA,aACA,kBACA,0BACA,kBACA,gBACA,mBACA,cACA,UACA,YACA,kBACA,YACA,cACA,aACA,OACA,OACA,iBACA,MACA,MACA,IACA,WACA,kBACA,kBACA,kBACA,0BACA,KACA,cACA,YACA,UACA,SACA,WACA,iBACA,mBACA,aACA,aACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,MAAMA,QAAM,GAAG;CACrB,MAAM,aAAa,sBAAsB,KAAK;CAC9C,MAAM,gBAAgB,iBAAiB,WAAW;CAClD,MAAM,WAAW,OAAyB,KAAK;CAC/C,MAAM,OAAO,aAAa,UAAU,IAAI;CAExC,MAAM,WAAW,YAAY;EAC3B,QAAQ;EACR,eAAe;EACf,sBAAsB;AACpB,qBAAkB;AAClB,OAAI,gCACF,UAAS,mBAAmB;;EAGhC,uBAAuB;AACrB,sBAAmB;AACnB,YAAS,qBAAqB;;EAEjC,CAAC;CAEF,MAAM,EACJ,YACA,MAAM,EAAE,MAAM,cAAc,G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KACoB,CAAA,CACb;;GACF,CAAA,EACW,CAAA,EAE1B,oBAAC,iBAAD;GACE,MAAM,iBAAiB;IAAE,MAAM;IAAY,OAAO;IAAQ,CAAC;GAC3D,QAAQ,YAAY;GACZ;GACR,QAAQ;GACD;GACP,iBAAA;GACgB;GACG;GACT;GACV,SAAS,QAAQ,GAAG,IAAI,UAAU,KAAA;GAClC,cAAY,QAAQ,KAAA,IAAY,OAAO;GACzB;GACG;GACjB,CAAA,CACO;KACX,oBAAC,SAAS,aAAV;EACQ;EACA;EACN,OAAO;EACP,eAAe;EACL;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,UAAU,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AACjE,UAAU,cAAc"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region packages/@mantine/core/src/core/utils/get-env/get-env.ts
|
|
3
3
|
function getEnv() {
|
|
4
|
-
if (typeof process !== "undefined" && process.env && "
|
|
4
|
+
if (typeof process !== "undefined" && process.env && "development") return "development";
|
|
5
5
|
return "development";
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-env.mjs","names":[],"sources":["../../../../src/core/utils/get-env/get-env.ts"],"sourcesContent":["export function getEnv() {\n if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV) {\n return process.env.NODE_ENV;\n }\n\n return 'development';\n}\n"],"mappings":";;AAAA,SAAgB,SAAS;AACvB,KAAI,OAAO,YAAY,eAAe,QAAQ,OAAA,
|
|
1
|
+
{"version":3,"file":"get-env.mjs","names":[],"sources":["../../../../src/core/utils/get-env/get-env.ts"],"sourcesContent":["export function getEnv() {\n if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV) {\n return process.env.NODE_ENV;\n }\n\n return 'development';\n}\n"],"mappings":";;AAAA,SAAgB,SAAS;AACvB,KAAI,OAAO,YAAY,eAAe,QAAQ,OAAA,cAC5C,QAAA;AAGF,QAAO"}
|
|
@@ -8,21 +8,5 @@ interface UseComboboxTargetPropsInput {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function useComboboxTargetProps({ onKeyDown, withKeyboardNavigation, withAriaAttributes, withExpandedAttribute, targetType, autoComplete, }: UseComboboxTargetPropsInput): {
|
|
10
10
|
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
11
|
-
'aria-haspopup': "listbox";
|
|
12
|
-
'aria-expanded': boolean | undefined;
|
|
13
|
-
'aria-controls': string | undefined;
|
|
14
|
-
'aria-activedescendant': string | undefined;
|
|
15
|
-
autoComplete: string | undefined;
|
|
16
|
-
'data-expanded': true | undefined;
|
|
17
|
-
'data-mantine-stop-propagation': true | undefined;
|
|
18
|
-
} | {
|
|
19
|
-
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
20
|
-
'aria-haspopup'?: undefined;
|
|
21
|
-
'aria-expanded'?: undefined;
|
|
22
|
-
'aria-controls'?: undefined;
|
|
23
|
-
'aria-activedescendant'?: undefined;
|
|
24
|
-
autoComplete?: undefined;
|
|
25
|
-
'data-expanded'?: undefined;
|
|
26
|
-
'data-mantine-stop-propagation'?: undefined;
|
|
27
11
|
};
|
|
28
12
|
export {};
|
|
@@ -8,4 +8,4 @@ export interface InputClearSectionProps {
|
|
|
8
8
|
size: MantineSize | string | undefined;
|
|
9
9
|
__clearSectionMode: ClearSectionMode | undefined;
|
|
10
10
|
}
|
|
11
|
-
export declare function InputClearSection({ __clearable, __clearSection, rightSection, __defaultRightSection, size, __clearSectionMode, }: InputClearSectionProps): string | number | bigint | boolean |
|
|
11
|
+
export declare function InputClearSection({ __clearable, __clearSection, rightSection, __defaultRightSection, size, __clearSectionMode, }: InputClearSectionProps): string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -8,7 +8,7 @@ interface BaseProps extends __BaseInputProps, BoxProps, StylesApiProps<{
|
|
|
8
8
|
__stylesApiProps?: Record<string, any>;
|
|
9
9
|
id?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare function useInputProps<T extends BaseProps, U extends Partial<T> | null>(component: string, defaultProps: U, _props: T): Omit<T & (U extends null | undefined ? {} : { [Key in Extract<keyof T, keyof U>]-?: U[Key] | NonNullable<T[Key]>; }), "style" | "
|
|
11
|
+
export declare function useInputProps<T extends BaseProps, U extends Partial<T> | null>(component: string, defaultProps: U, _props: T): Omit<T & (U extends null | undefined ? {} : { [Key in Extract<keyof T, keyof U>]-?: U[Key] | NonNullable<T[Key]>; }), "label" | "style" | "size" | "styles" | "className" | "id" | "vars" | "variant" | "unstyled" | "attributes" | "classNames" | "mod" | "description" | "error" | "__staticSelector" | "required" | "__stylesApiProps" | "withAsterisk" | "labelProps" | "descriptionProps" | "errorProps" | "inputContainer" | "inputWrapperOrder" | "wrapperProps"> & {
|
|
12
12
|
classNames: Partial<Record<string, string>> | ((theme: import("../..").MantineTheme, props: any, ctx: unknown) => Partial<Record<string, string>>) | undefined;
|
|
13
13
|
styles: Partial<Record<string, import("../..").CSSProperties>> | ((theme: import("../..").MantineTheme, props: any, ctx: unknown) => Partial<Record<string, import("../..").CSSProperties>>) | undefined;
|
|
14
14
|
unstyled: boolean | undefined;
|
|
@@ -23,17 +23,17 @@ export declare function useInputProps<T extends BaseProps, U extends Partial<T>
|
|
|
23
23
|
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
|
|
24
24
|
autoFocus?: boolean | undefined;
|
|
25
25
|
className: string | undefined;
|
|
26
|
-
contentEditable?: (boolean | "
|
|
26
|
+
contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only" | undefined;
|
|
27
27
|
contextMenu?: string | undefined;
|
|
28
28
|
dir?: string | undefined;
|
|
29
|
-
draggable?: (boolean | "
|
|
29
|
+
draggable?: (boolean | "false" | "true") | undefined;
|
|
30
30
|
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
31
31
|
hidden?: boolean | undefined;
|
|
32
32
|
id: string | undefined;
|
|
33
33
|
lang?: string | undefined;
|
|
34
34
|
nonce?: string | undefined;
|
|
35
35
|
slot?: string | undefined;
|
|
36
|
-
spellCheck?: (boolean | "
|
|
36
|
+
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
37
37
|
style: import("react").CSSProperties | ((theme: import("../..").MantineTheme) => import("../..").CSSProperties) | import("../..").MantineStyleProp[] | undefined;
|
|
38
38
|
tabIndex?: number | undefined;
|
|
39
39
|
title?: string | undefined;
|
|
@@ -71,11 +71,11 @@ export declare function useInputProps<T extends BaseProps, U extends Partial<T>
|
|
|
71
71
|
exportparts?: string | undefined;
|
|
72
72
|
part?: string | undefined;
|
|
73
73
|
"aria-activedescendant"?: string | undefined;
|
|
74
|
-
"aria-atomic"?: (boolean | "
|
|
74
|
+
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
|
75
75
|
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
|
|
76
76
|
"aria-braillelabel"?: string | undefined;
|
|
77
77
|
"aria-brailleroledescription"?: string | undefined;
|
|
78
|
-
"aria-busy"?: (boolean | "
|
|
78
|
+
"aria-busy"?: (boolean | "false" | "true") | undefined;
|
|
79
79
|
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
80
80
|
"aria-colcount"?: number | undefined;
|
|
81
81
|
"aria-colindex"?: number | undefined;
|
|
@@ -86,37 +86,37 @@ export declare function useInputProps<T extends BaseProps, U extends Partial<T>
|
|
|
86
86
|
"aria-describedby"?: string | undefined;
|
|
87
87
|
"aria-description"?: string | undefined;
|
|
88
88
|
"aria-details"?: string | undefined;
|
|
89
|
-
"aria-disabled"?: (boolean | "
|
|
89
|
+
"aria-disabled"?: (boolean | "false" | "true") | undefined;
|
|
90
90
|
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
|
|
91
91
|
"aria-errormessage"?: string | undefined;
|
|
92
|
-
"aria-expanded"?: (boolean | "
|
|
92
|
+
"aria-expanded"?: (boolean | "false" | "true") | undefined;
|
|
93
93
|
"aria-flowto"?: string | undefined;
|
|
94
|
-
"aria-grabbed"?: (boolean | "
|
|
94
|
+
"aria-grabbed"?: (boolean | "false" | "true") | undefined;
|
|
95
95
|
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
|
|
96
|
-
"aria-hidden"?: (boolean | "
|
|
96
|
+
"aria-hidden"?: (boolean | "false" | "true") | undefined;
|
|
97
97
|
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
|
98
98
|
"aria-keyshortcuts"?: string | undefined;
|
|
99
99
|
"aria-label"?: string | undefined;
|
|
100
100
|
"aria-labelledby"?: string | undefined;
|
|
101
101
|
"aria-level"?: number | undefined;
|
|
102
102
|
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
103
|
-
"aria-modal"?: (boolean | "
|
|
104
|
-
"aria-multiline"?: (boolean | "
|
|
105
|
-
"aria-multiselectable"?: (boolean | "
|
|
103
|
+
"aria-modal"?: (boolean | "false" | "true") | undefined;
|
|
104
|
+
"aria-multiline"?: (boolean | "false" | "true") | undefined;
|
|
105
|
+
"aria-multiselectable"?: (boolean | "false" | "true") | undefined;
|
|
106
106
|
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
107
107
|
"aria-owns"?: string | undefined;
|
|
108
108
|
"aria-placeholder"?: string | undefined;
|
|
109
109
|
"aria-posinset"?: number | undefined;
|
|
110
110
|
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
111
|
-
"aria-readonly"?: (boolean | "
|
|
111
|
+
"aria-readonly"?: (boolean | "false" | "true") | undefined;
|
|
112
112
|
"aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
|
|
113
|
-
"aria-required"?: (boolean | "
|
|
113
|
+
"aria-required"?: (boolean | "false" | "true") | undefined;
|
|
114
114
|
"aria-roledescription"?: string | undefined;
|
|
115
115
|
"aria-rowcount"?: number | undefined;
|
|
116
116
|
"aria-rowindex"?: number | undefined;
|
|
117
117
|
"aria-rowindextext"?: string | undefined;
|
|
118
118
|
"aria-rowspan"?: number | undefined;
|
|
119
|
-
"aria-selected"?: (boolean | "
|
|
119
|
+
"aria-selected"?: (boolean | "false" | "true") | undefined;
|
|
120
120
|
"aria-setsize"?: number | undefined;
|
|
121
121
|
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
122
122
|
"aria-valuemax"?: number | undefined;
|
|
@@ -307,7 +307,7 @@ export declare function useInputProps<T extends BaseProps, U extends Partial<T>
|
|
|
307
307
|
descriptionProps: (import(".").InputDescriptionProps & import("../..").DataAttributes) | undefined;
|
|
308
308
|
unstyled: boolean | undefined;
|
|
309
309
|
styles: Partial<Record<string, import("../..").CSSProperties>> | ((theme: import("../..").MantineTheme, props: any, ctx: unknown) => Partial<Record<string, import("../..").CSSProperties>>) | undefined;
|
|
310
|
-
size: import("../..").MantineSize |
|
|
310
|
+
size: (string & {}) | import("../..").MantineSize | undefined;
|
|
311
311
|
inputContainer: ((children: React.ReactNode) => React.ReactNode) | undefined;
|
|
312
312
|
inputWrapperOrder: ("input" | "label" | "description" | "error")[] | undefined;
|
|
313
313
|
withAsterisk: boolean | undefined;
|
|
@@ -322,7 +322,7 @@ export declare function useInputProps<T extends BaseProps, U extends Partial<T>
|
|
|
322
322
|
classNames: Partial<Record<string, string>> | ((theme: import("../..").MantineTheme, props: any, ctx: unknown) => Partial<Record<string, string>>) | undefined;
|
|
323
323
|
styles: Partial<Record<string, import("../..").CSSProperties>> | ((theme: import("../..").MantineTheme, props: any, ctx: unknown) => Partial<Record<string, import("../..").CSSProperties>>) | undefined;
|
|
324
324
|
unstyled: boolean | undefined;
|
|
325
|
-
size: import("../..").MantineSize |
|
|
325
|
+
size: (string & {}) | import("../..").MantineSize | undefined;
|
|
326
326
|
__staticSelector: string | undefined;
|
|
327
327
|
__stylesApiProps: Record<string, any> | BaseProps;
|
|
328
328
|
error: import("react").ReactNode;
|
|
@@ -43,10 +43,10 @@ export declare function usePopover(options: UsePopoverOptions): {
|
|
|
43
43
|
floating: HTMLElement | null;
|
|
44
44
|
} & import("@floating-ui/react").ExtendedElements<Element>;
|
|
45
45
|
context: {
|
|
46
|
-
strategy: import("@floating-ui/utils").Strategy;
|
|
47
|
-
placement: import("@floating-ui/utils").Placement;
|
|
48
46
|
x: number;
|
|
49
47
|
y: number;
|
|
48
|
+
placement: import("@floating-ui/utils").Placement;
|
|
49
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
50
50
|
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
51
51
|
isPositioned: boolean;
|
|
52
52
|
update: () => void;
|
|
@@ -4,6 +4,6 @@ interface GetContrastColorInput {
|
|
|
4
4
|
theme: MantineTheme;
|
|
5
5
|
autoContrast?: boolean | undefined | null;
|
|
6
6
|
}
|
|
7
|
-
export declare function getContrastColor({ color, theme, autoContrast }: GetContrastColorInput): "var(--mantine-color-
|
|
8
|
-
export declare function getPrimaryContrastColor(theme: MantineTheme, colorScheme: 'light' | 'dark'): "var(--mantine-color-
|
|
7
|
+
export declare function getContrastColor({ color, theme, autoContrast }: GetContrastColorInput): "var(--mantine-color-black)" | "var(--mantine-color-white)";
|
|
8
|
+
export declare function getPrimaryContrastColor(theme: MantineTheme, colorScheme: 'light' | 'dark'): "var(--mantine-color-black)" | "var(--mantine-color-white)";
|
|
9
9
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantine/core",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.7",
|
|
4
4
|
"description": "React components library focused on usability, accessibility and developer experience",
|
|
5
5
|
"homepage": "https://mantine.dev/",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"directory": "packages/@mantine/core"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@mantine/hooks": "9.0.0-alpha.
|
|
46
|
+
"@mantine/hooks": "9.0.0-alpha.7",
|
|
47
47
|
"react": "^19.2.0",
|
|
48
48
|
"react-dom": "^19.2.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@floating-ui/react": "^0.27.19",
|
|
52
52
|
"clsx": "^2.1.1",
|
|
53
|
-
"react-number-format": "^5.4.
|
|
53
|
+
"react-number-format": "^5.4.5",
|
|
54
54
|
"react-remove-scroll": "^2.7.2",
|
|
55
|
-
"type-fest": "^
|
|
55
|
+
"type-fest": "^5.5.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@mantine-tests/core": "workspace:*",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
|
|
4
|
-
const require_factory = require("../../core/factory/factory.cjs");
|
|
5
|
-
const require_InputBase = require("../InputBase/InputBase.cjs");
|
|
6
|
-
const require_use_mask_input_props = require("./use-mask-input-props.cjs");
|
|
7
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
-
//#region packages/@mantine/core/src/components/MaskInput/MaskInput.tsx
|
|
9
|
-
const defaultProps = {};
|
|
10
|
-
const MaskInput = require_factory.factory((props) => {
|
|
11
|
-
const { maskRef, elementProps } = require_use_mask_input_props.useMaskInputProps(require_use_props.useProps("MaskInput", defaultProps, props));
|
|
12
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InputBase.InputBase, {
|
|
13
|
-
component: "input",
|
|
14
|
-
ref: maskRef,
|
|
15
|
-
...elementProps,
|
|
16
|
-
__staticSelector: "MaskInput"
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
MaskInput.classes = require_InputBase.InputBase.classes;
|
|
20
|
-
MaskInput.displayName = "@mantine/core/MaskInput";
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.MaskInput = MaskInput;
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=MaskInput.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MaskInput.cjs","names":["factory","useMaskInputProps","useProps","InputBase"],"sources":["../../../src/components/MaskInput/MaskInput.tsx"],"sourcesContent":["import { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { useMaskInputProps } from './use-mask-input-props';\n\nexport interface MaskInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<MaskInputFactory>,\n ElementProps<'input', 'size'> {\n /** Mask pattern string or array of string literals and RegExp objects */\n mask: string | Array<string | RegExp>;\n\n /** Override or extend the default token map */\n tokens?: Record<string, RegExp>;\n\n /** Called before masking on each keystroke, can return overrides for mask options */\n modify?: (\n value: string\n ) => Partial<Pick<MaskInputProps, 'mask' | 'tokens' | 'slotChar' | 'separate'>> | undefined;\n\n /** When true, raw and display values are decoupled */\n separate?: boolean;\n\n /** Character displayed in unfilled slots, `\"_\"` by default */\n slotChar?: string | null;\n\n /** Show mask pattern even when field is empty and unfocused */\n alwaysShowMask?: boolean;\n\n /** Show mask placeholder on focus, `true` by default */\n showMaskOnFocus?: boolean;\n\n /** Transform each character before validation and insertion */\n transform?: (char: string) => string;\n\n /** Clear value on blur when mask is incomplete, `false` by default */\n autoClear?: boolean;\n\n /** Called on every change with raw and masked values */\n onChangeRaw?: (rawValue: string, maskedValue: string) => void;\n\n /** Called when all required mask slots are filled */\n onComplete?: (maskedValue: string, rawValue: string) => void;\n\n /** Escape hatch for advanced cursor/value manipulation */\n beforeMaskedStateChange?: (states: {\n previousState: { value: string; selection: { start: number; end: number } | null };\n currentState: { value: string; selection: { start: number; end: number } | null };\n nextState: { value: string; selection: { start: number; end: number } | null };\n }) => { value: string; selection: { start: number; end: number } | null };\n}\n\nexport type MaskInputFactory = Factory<{\n props: MaskInputProps;\n variant: InputVariant;\n ref: HTMLInputElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {} satisfies Partial<MaskInputProps>;\n\nexport const MaskInput = factory<MaskInputFactory>((props) => {\n const _props = useProps('MaskInput', defaultProps, props);\n const { maskRef, elementProps } = useMaskInputProps(_props);\n\n return (\n <InputBase\n component=\"input\"\n ref={maskRef}\n {...(elementProps as any)}\n __staticSelector=\"MaskInput\"\n />\n );\n});\n\nMaskInput.classes = InputBase.classes;\nMaskInput.displayName = '@mantine/core/MaskInput';\n"],"mappings":";;;;;;;;AA6DA,MAAM,eAAe,EAAE;AAEvB,MAAa,YAAYA,gBAAAA,SAA2B,UAAU;CAE5D,MAAM,EAAE,SAAS,iBAAiBC,6BAAAA,kBADnBC,kBAAAA,SAAS,aAAa,cAAc,MAAM,CACE;AAE3D,QACE,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;EACE,WAAU;EACV,KAAK;EACL,GAAK;EACL,kBAAiB;EACjB,CAAA;EAEJ;AAEF,UAAU,UAAUA,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
let _mantine_hooks = require("@mantine/hooks");
|
|
4
|
-
//#region packages/@mantine/core/src/components/MaskInput/use-mask-input-props.ts
|
|
5
|
-
function useMaskInputProps(props) {
|
|
6
|
-
const { mask, tokens, modify, separate, slotChar, alwaysShowMask, showMaskOnFocus, transform, autoClear, onChangeRaw, onComplete, beforeMaskedStateChange, ref, ...elementProps } = props;
|
|
7
|
-
const { ref: maskCallbackRef } = (0, _mantine_hooks.useMask)({
|
|
8
|
-
mask,
|
|
9
|
-
tokens,
|
|
10
|
-
modify,
|
|
11
|
-
separate,
|
|
12
|
-
slotChar,
|
|
13
|
-
alwaysShowMask,
|
|
14
|
-
showMaskOnFocus,
|
|
15
|
-
transform,
|
|
16
|
-
autoClear,
|
|
17
|
-
onChangeRaw,
|
|
18
|
-
onComplete,
|
|
19
|
-
beforeMaskedStateChange
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
maskRef: (0, _mantine_hooks.useMergedRef)(ref, maskCallbackRef),
|
|
23
|
-
elementProps
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.useMaskInputProps = useMaskInputProps;
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=use-mask-input-props.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-mask-input-props.cjs","names":[],"sources":["../../../src/components/MaskInput/use-mask-input-props.ts"],"sourcesContent":["import { useMask, useMergedRef } from '@mantine/hooks';\nimport type { MaskInputProps } from './MaskInput';\n\nexport function useMaskInputProps(props: MaskInputProps & { ref?: React.Ref<HTMLInputElement> }) {\n const {\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n ref,\n ...elementProps\n } = props;\n\n const { ref: maskCallbackRef } = useMask({\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n });\n\n const maskRef = useMergedRef(ref, maskCallbackRef);\n\n return { maskRef, elementProps };\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAAkB,OAA+D;CAC/F,MAAM,EACJ,MACA,QACA,QACA,UACA,UACA,gBACA,iBACA,WACA,WACA,aACA,YACA,yBACA,KACA,GAAG,iBACD;CAEJ,MAAM,EAAE,KAAK,qBAAA,GAAA,eAAA,SAA4B;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAIF,QAAO;EAAE,UAAA,GAAA,eAAA,cAFoB,KAAK,gBAAgB;EAEhC;EAAc"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
require("../../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
const require_use_props = require("../../../core/MantineProvider/use-props/use-props.cjs");
|
|
4
|
-
const require_factory = require("../../../core/factory/factory.cjs");
|
|
5
|
-
const require_Box = require("../../../core/Box/Box.cjs");
|
|
6
|
-
const require_Pagination_context = require("../Pagination.context.cjs");
|
|
7
|
-
const require_Pagination_module = require("../Pagination.module.cjs");
|
|
8
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
-
//#region packages/@mantine/core/src/components/Pagination/PaginationLabel/PaginationLabel.tsx
|
|
10
|
-
const defaultProps = { formatLabel: ({ page, totalPages }) => `Page ${page} of ${totalPages}` };
|
|
11
|
-
const PaginationLabel = require_factory.factory((_props) => {
|
|
12
|
-
const { classNames, className, style, styles, vars, formatLabel, ...others } = require_use_props.useProps("PaginationLabel", defaultProps, _props);
|
|
13
|
-
const ctx = require_Pagination_context.usePaginationContext();
|
|
14
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
15
|
-
...ctx.getStyles("label", {
|
|
16
|
-
className,
|
|
17
|
-
style,
|
|
18
|
-
styles,
|
|
19
|
-
classNames
|
|
20
|
-
}),
|
|
21
|
-
...others,
|
|
22
|
-
children: formatLabel({
|
|
23
|
-
page: ctx.active,
|
|
24
|
-
totalPages: ctx.total
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
PaginationLabel.classes = require_Pagination_module.default;
|
|
29
|
-
PaginationLabel.displayName = "@mantine/core/PaginationLabel";
|
|
30
|
-
//#endregion
|
|
31
|
-
exports.PaginationLabel = PaginationLabel;
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=PaginationLabel.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PaginationLabel.cjs","names":["factory","useProps","usePaginationContext","Box","classes"],"sources":["../../../../src/components/Pagination/PaginationLabel/PaginationLabel.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n CompoundStylesApiProps,\n ElementProps,\n factory,\n Factory,\n useProps,\n} from '../../../core';\nimport { usePaginationContext } from '../Pagination.context';\nimport classes from '../Pagination.module.css';\n\nexport type PaginationFormatLabel = (input: { page: number; totalPages: number }) => string;\nexport type PaginationLabelStylesNames = 'label';\n\nexport interface PaginationLabelProps\n extends BoxProps, CompoundStylesApiProps<PaginationLabelFactory>, ElementProps<'div'> {\n /** Function to format the label text */\n formatLabel?: PaginationFormatLabel;\n}\n\nexport type PaginationLabelFactory = Factory<{\n props: PaginationLabelProps;\n ref: HTMLDivElement;\n stylesNames: PaginationLabelStylesNames;\n compound: true;\n}>;\n\nconst defaultProps = {\n formatLabel: ({ page, totalPages }) => `Page ${page} of ${totalPages}`,\n} satisfies Partial<PaginationLabelProps>;\n\nexport const PaginationLabel = factory<PaginationLabelFactory>((_props) => {\n const props = useProps('PaginationLabel', defaultProps, _props);\n const { classNames, className, style, styles, vars, formatLabel, ...others } = props;\n const ctx = usePaginationContext();\n\n return (\n <Box {...ctx.getStyles('label', { className, style, styles, classNames })} {...others}>\n {formatLabel({ page: ctx.active, totalPages: ctx.total })}\n </Box>\n );\n});\n\nPaginationLabel.classes = classes;\nPaginationLabel.displayName = '@mantine/core/PaginationLabel';\n"],"mappings":";;;;;;;;;AA4BA,MAAM,eAAe,EACnB,cAAc,EAAE,MAAM,iBAAiB,QAAQ,KAAK,MAAM,cAC3D;AAED,MAAa,kBAAkBA,gBAAAA,SAAiC,WAAW;CAEzE,MAAM,EAAE,YAAY,WAAW,OAAO,QAAQ,MAAM,aAAa,GAAG,WADtDC,kBAAAA,SAAS,mBAAmB,cAAc,OAAO;CAE/D,MAAM,MAAMC,2BAAAA,sBAAsB;AAElC,QACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EAAK,GAAI,IAAI,UAAU,SAAS;GAAE;GAAW;GAAO;GAAQ;GAAY,CAAC;EAAE,GAAI;YAC5E,YAAY;GAAE,MAAM,IAAI;GAAQ,YAAY,IAAI;GAAO,CAAC;EACrD,CAAA;EAER;AAEF,gBAAgB,UAAUC,0BAAAA;AAC1B,gBAAgB,cAAc"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
-
//#region packages/@mantine/core/src/components/RollingNumber/DigitColumn.tsx
|
|
5
|
-
const DIGITS = [
|
|
6
|
-
"0",
|
|
7
|
-
"1",
|
|
8
|
-
"2",
|
|
9
|
-
"3",
|
|
10
|
-
"4",
|
|
11
|
-
"5",
|
|
12
|
-
"6",
|
|
13
|
-
"7",
|
|
14
|
-
"8",
|
|
15
|
-
"9"
|
|
16
|
-
];
|
|
17
|
-
function DigitColumn({ digit, getStyles, previousDigit, empty }) {
|
|
18
|
-
const digitIndex = DIGITS.indexOf(digit);
|
|
19
|
-
const prevIndex = previousDigit !== null ? DIGITS.indexOf(previousDigit) : -1;
|
|
20
|
-
const direction = prevIndex === -1 || digitIndex >= prevIndex ? "up" : "down";
|
|
21
|
-
const digitStyles = getStyles("digit");
|
|
22
|
-
const columnStyles = getStyles("digitColumn");
|
|
23
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
24
|
-
...digitStyles,
|
|
25
|
-
"data-empty": empty || void 0,
|
|
26
|
-
"aria-hidden": "true",
|
|
27
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
28
|
-
...columnStyles,
|
|
29
|
-
style: {
|
|
30
|
-
...columnStyles.style,
|
|
31
|
-
transform: `translateY(${-digitIndex}em)`
|
|
32
|
-
},
|
|
33
|
-
"data-direction": direction,
|
|
34
|
-
children: DIGITS.map((d) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: d }, d))
|
|
35
|
-
})
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
exports.DigitColumn = DigitColumn;
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=DigitColumn.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DigitColumn.cjs","names":[],"sources":["../../../src/components/RollingNumber/DigitColumn.tsx"],"sourcesContent":["import { useStyles } from '../../core';\nimport type { RollingNumberFactory } from './RollingNumber';\n\nconst DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\n\ninterface DigitColumnProps {\n digit: string;\n getStyles: ReturnType<typeof useStyles<RollingNumberFactory>>;\n previousDigit: string | null;\n empty?: boolean;\n}\n\nexport function DigitColumn({ digit, getStyles, previousDigit, empty }: DigitColumnProps) {\n const digitIndex = DIGITS.indexOf(digit);\n const prevIndex = previousDigit !== null ? DIGITS.indexOf(previousDigit) : -1;\n const direction = prevIndex === -1 || digitIndex >= prevIndex ? 'up' : 'down';\n const digitStyles = getStyles('digit');\n const columnStyles = getStyles('digitColumn');\n\n return (\n <span {...digitStyles} data-empty={empty || undefined} aria-hidden=\"true\">\n <span\n {...columnStyles}\n style={{ ...columnStyles.style, transform: `translateY(${-digitIndex}em)` }}\n data-direction={direction}\n >\n {DIGITS.map((d) => (\n <span key={d}>{d}</span>\n ))}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;AAGA,MAAM,SAAS;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;AASjE,SAAgB,YAAY,EAAE,OAAO,WAAW,eAAe,SAA2B;CACxF,MAAM,aAAa,OAAO,QAAQ,MAAM;CACxC,MAAM,YAAY,kBAAkB,OAAO,OAAO,QAAQ,cAAc,GAAG;CAC3E,MAAM,YAAY,cAAc,MAAM,cAAc,YAAY,OAAO;CACvE,MAAM,cAAc,UAAU,QAAQ;CACtC,MAAM,eAAe,UAAU,cAAc;AAE7C,QACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EAAM,GAAI;EAAa,cAAY,SAAS,KAAA;EAAW,eAAY;YACjE,iBAAA,GAAA,kBAAA,KAAC,QAAD;GACE,GAAI;GACJ,OAAO;IAAE,GAAG,aAAa;IAAO,WAAW,cAAc,CAAC,WAAW;IAAM;GAC3E,kBAAgB;aAEf,OAAO,KAAK,MACX,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAA,UAAe,GAAS,EAAb,EAAa,CACxB;GACG,CAAA;EACF,CAAA"}
|