@mantine/core 9.1.1 → 9.2.0

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.
Files changed (165) hide show
  1. package/cjs/components/Autocomplete/Autocomplete.cjs +5 -1
  2. package/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
  3. package/cjs/components/Checkbox/Checkbox.cjs +4 -1
  4. package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
  5. package/cjs/components/ColorInput/ColorInput.cjs +5 -1
  6. package/cjs/components/ColorInput/ColorInput.cjs.map +1 -1
  7. package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs +17 -0
  8. package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs.map +1 -0
  9. package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs +170 -0
  10. package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs.map +1 -0
  11. package/cjs/components/FileInput/FileInput.cjs +5 -1
  12. package/cjs/components/FileInput/FileInput.cjs.map +1 -1
  13. package/cjs/components/Input/use-input-props.cjs +5 -1
  14. package/cjs/components/Input/use-input-props.cjs.map +1 -1
  15. package/cjs/components/JsonInput/JsonInput.cjs +5 -2
  16. package/cjs/components/JsonInput/JsonInput.cjs.map +1 -1
  17. package/cjs/components/MaskInput/MaskInput.cjs +5 -1
  18. package/cjs/components/MaskInput/MaskInput.cjs.map +1 -1
  19. package/cjs/components/MaskInput/use-mask-input-props.cjs +3 -2
  20. package/cjs/components/MaskInput/use-mask-input-props.cjs.map +1 -1
  21. package/cjs/components/MultiSelect/MultiSelect.cjs +19 -3
  22. package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
  23. package/cjs/components/NativeSelect/NativeSelect.cjs +5 -1
  24. package/cjs/components/NativeSelect/NativeSelect.cjs.map +1 -1
  25. package/cjs/components/NumberInput/NumberInput.cjs +5 -1
  26. package/cjs/components/NumberInput/NumberInput.cjs.map +1 -1
  27. package/cjs/components/PasswordInput/PasswordInput.cjs +5 -1
  28. package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
  29. package/cjs/components/Pill/Pill.module.cjs.map +1 -1
  30. package/cjs/components/PillsInput/PillsInput.cjs +5 -1
  31. package/cjs/components/PillsInput/PillsInput.cjs.map +1 -1
  32. package/cjs/components/PinInput/PinInput.cjs +1 -1
  33. package/cjs/components/PinInput/PinInput.cjs.map +1 -1
  34. package/cjs/components/RollingNumber/DigitColumn.cjs +46 -0
  35. package/cjs/components/RollingNumber/DigitColumn.cjs.map +1 -0
  36. package/cjs/components/RollingNumber/RollingNumber.cjs +102 -0
  37. package/cjs/components/RollingNumber/RollingNumber.cjs.map +1 -0
  38. package/cjs/components/RollingNumber/RollingNumber.module.cjs +13 -0
  39. package/cjs/components/RollingNumber/RollingNumber.module.cjs.map +1 -0
  40. package/cjs/components/RollingNumber/build-value.cjs +22 -0
  41. package/cjs/components/RollingNumber/build-value.cjs.map +1 -0
  42. package/cjs/components/RollingNumber/get-digit-parts.cjs +40 -0
  43. package/cjs/components/RollingNumber/get-digit-parts.cjs.map +1 -0
  44. package/cjs/components/RollingNumber/get-render-slots.cjs +78 -0
  45. package/cjs/components/RollingNumber/get-render-slots.cjs.map +1 -0
  46. package/cjs/components/Select/Select.cjs +5 -1
  47. package/cjs/components/Select/Select.cjs.map +1 -1
  48. package/cjs/components/TagsInput/TagsInput.cjs +19 -4
  49. package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
  50. package/cjs/components/TextInput/TextInput.cjs +5 -1
  51. package/cjs/components/TextInput/TextInput.cjs.map +1 -1
  52. package/cjs/components/Textarea/Textarea.cjs +5 -2
  53. package/cjs/components/Textarea/Textarea.cjs.map +1 -1
  54. package/cjs/components/Tree/is-node-checked/is-node-checked.cjs +1 -0
  55. package/cjs/components/Tree/is-node-indeterminate/is-node-indeterminate.cjs +1 -0
  56. package/cjs/components/TreeSelect/TreeSelect.cjs +601 -0
  57. package/cjs/components/TreeSelect/TreeSelect.cjs.map +1 -0
  58. package/cjs/components/TreeSelect/TreeSelect.module.cjs +16 -0
  59. package/cjs/components/TreeSelect/TreeSelect.module.cjs.map +1 -0
  60. package/cjs/components/TreeSelect/TreeSelectOption.cjs +95 -0
  61. package/cjs/components/TreeSelect/TreeSelectOption.cjs.map +1 -0
  62. package/cjs/components/TreeSelect/flatten-tree-select-data.cjs +34 -0
  63. package/cjs/components/TreeSelect/flatten-tree-select-data.cjs.map +1 -0
  64. package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs +30 -0
  65. package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs.map +1 -0
  66. package/cjs/core/MantineProvider/use-props/use-props.cjs +10 -2
  67. package/cjs/core/MantineProvider/use-props/use-props.cjs.map +1 -1
  68. package/cjs/index.cjs +8 -0
  69. package/esm/components/Autocomplete/Autocomplete.mjs +5 -1
  70. package/esm/components/Autocomplete/Autocomplete.mjs.map +1 -1
  71. package/esm/components/Checkbox/Checkbox.mjs +4 -1
  72. package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
  73. package/esm/components/ColorInput/ColorInput.mjs +5 -1
  74. package/esm/components/ColorInput/ColorInput.mjs.map +1 -1
  75. package/esm/components/Combobox/use-pills-reorder/move-pill.mjs +17 -0
  76. package/esm/components/Combobox/use-pills-reorder/move-pill.mjs.map +1 -0
  77. package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs +169 -0
  78. package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs.map +1 -0
  79. package/esm/components/FileInput/FileInput.mjs +5 -1
  80. package/esm/components/FileInput/FileInput.mjs.map +1 -1
  81. package/esm/components/Input/use-input-props.mjs +5 -1
  82. package/esm/components/Input/use-input-props.mjs.map +1 -1
  83. package/esm/components/JsonInput/JsonInput.mjs +5 -2
  84. package/esm/components/JsonInput/JsonInput.mjs.map +1 -1
  85. package/esm/components/MaskInput/MaskInput.mjs +5 -1
  86. package/esm/components/MaskInput/MaskInput.mjs.map +1 -1
  87. package/esm/components/MaskInput/use-mask-input-props.mjs +4 -3
  88. package/esm/components/MaskInput/use-mask-input-props.mjs.map +1 -1
  89. package/esm/components/MultiSelect/MultiSelect.mjs +19 -3
  90. package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
  91. package/esm/components/NativeSelect/NativeSelect.mjs +5 -1
  92. package/esm/components/NativeSelect/NativeSelect.mjs.map +1 -1
  93. package/esm/components/NumberInput/NumberInput.mjs +5 -1
  94. package/esm/components/NumberInput/NumberInput.mjs.map +1 -1
  95. package/esm/components/PasswordInput/PasswordInput.mjs +5 -1
  96. package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
  97. package/esm/components/Pill/Pill.module.mjs.map +1 -1
  98. package/esm/components/PillsInput/PillsInput.mjs +5 -1
  99. package/esm/components/PillsInput/PillsInput.mjs.map +1 -1
  100. package/esm/components/PinInput/PinInput.mjs +1 -1
  101. package/esm/components/PinInput/PinInput.mjs.map +1 -1
  102. package/esm/components/RollingNumber/DigitColumn.mjs +45 -0
  103. package/esm/components/RollingNumber/DigitColumn.mjs.map +1 -0
  104. package/esm/components/RollingNumber/RollingNumber.mjs +101 -0
  105. package/esm/components/RollingNumber/RollingNumber.mjs.map +1 -0
  106. package/esm/components/RollingNumber/RollingNumber.module.mjs +13 -0
  107. package/esm/components/RollingNumber/RollingNumber.module.mjs.map +1 -0
  108. package/esm/components/RollingNumber/build-value.mjs +22 -0
  109. package/esm/components/RollingNumber/build-value.mjs.map +1 -0
  110. package/esm/components/RollingNumber/get-digit-parts.mjs +40 -0
  111. package/esm/components/RollingNumber/get-digit-parts.mjs.map +1 -0
  112. package/esm/components/RollingNumber/get-render-slots.mjs +78 -0
  113. package/esm/components/RollingNumber/get-render-slots.mjs.map +1 -0
  114. package/esm/components/Select/Select.mjs +5 -1
  115. package/esm/components/Select/Select.mjs.map +1 -1
  116. package/esm/components/TagsInput/TagsInput.mjs +19 -4
  117. package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
  118. package/esm/components/TextInput/TextInput.mjs +5 -1
  119. package/esm/components/TextInput/TextInput.mjs.map +1 -1
  120. package/esm/components/Textarea/Textarea.mjs +5 -2
  121. package/esm/components/Textarea/Textarea.mjs.map +1 -1
  122. package/esm/components/Tree/is-node-checked/is-node-checked.mjs +1 -1
  123. package/esm/components/Tree/is-node-indeterminate/is-node-indeterminate.mjs +1 -1
  124. package/esm/components/TreeSelect/TreeSelect.mjs +600 -0
  125. package/esm/components/TreeSelect/TreeSelect.mjs.map +1 -0
  126. package/esm/components/TreeSelect/TreeSelect.module.mjs +16 -0
  127. package/esm/components/TreeSelect/TreeSelect.module.mjs.map +1 -0
  128. package/esm/components/TreeSelect/TreeSelectOption.mjs +94 -0
  129. package/esm/components/TreeSelect/TreeSelectOption.mjs.map +1 -0
  130. package/esm/components/TreeSelect/flatten-tree-select-data.mjs +34 -0
  131. package/esm/components/TreeSelect/flatten-tree-select-data.mjs.map +1 -0
  132. package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs +29 -0
  133. package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs.map +1 -0
  134. package/esm/core/MantineProvider/use-props/use-props.mjs +10 -2
  135. package/esm/core/MantineProvider/use-props/use-props.mjs.map +1 -1
  136. package/esm/index.mjs +5 -1
  137. package/lib/components/Combobox/Combobox.types.d.ts +3 -0
  138. package/lib/components/Combobox/index.d.ts +2 -0
  139. package/lib/components/Combobox/use-pills-reorder/move-pill.d.ts +2 -0
  140. package/lib/components/Combobox/use-pills-reorder/use-pills-reorder.d.ts +26 -0
  141. package/lib/components/MaskInput/MaskInput.d.ts +2 -0
  142. package/lib/components/MultiSelect/MultiSelect.d.ts +2 -0
  143. package/lib/components/RollingNumber/DigitColumn.d.ts +11 -0
  144. package/lib/components/RollingNumber/RollingNumber.d.ts +41 -0
  145. package/lib/components/RollingNumber/build-value.d.ts +10 -0
  146. package/lib/components/RollingNumber/get-digit-parts.d.ts +12 -0
  147. package/lib/components/RollingNumber/get-render-slots.d.ts +35 -0
  148. package/lib/components/RollingNumber/index.d.ts +9 -0
  149. package/lib/components/TagsInput/TagsInput.d.ts +2 -0
  150. package/lib/components/TreeSelect/TreeSelect.d.ts +124 -0
  151. package/lib/components/TreeSelect/TreeSelectOption.d.ts +36 -0
  152. package/lib/components/TreeSelect/flatten-tree-select-data.d.ts +12 -0
  153. package/lib/components/TreeSelect/get-checked-values-by-strategy.d.ts +4 -0
  154. package/lib/components/TreeSelect/index.d.ts +13 -0
  155. package/lib/components/index.d.ts +2 -0
  156. package/lib/core/MantineProvider/use-props/use-props.d.ts +1 -1
  157. package/package.json +2 -2
  158. package/styles/Pill.css +35 -0
  159. package/styles/Pill.layer.css +35 -0
  160. package/styles/RollingNumber.css +60 -0
  161. package/styles/RollingNumber.layer.css +61 -0
  162. package/styles/TreeSelect.css +113 -0
  163. package/styles/TreeSelect.layer.css +114 -0
  164. package/styles.css +210 -0
  165. package/styles.layer.css +210 -0
@@ -1 +1 @@
1
- {"version":3,"file":"MultiSelect.mjs","names":["useId"],"sources":["../../../src/components/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n genericFactory,\n MantineColor,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n Combobox,\n ComboboxItem,\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 { filterPickedValues } from './filter-picked-values';\n\nconst clearSectionOffset: Record<string, number> = {\n xs: 41,\n sm: 50,\n md: 60,\n lg: 72,\n xl: 89,\n};\n\nexport type MultiSelectStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport interface MultiSelectProps<Value extends Primitive = string>\n extends\n BoxProps,\n __BaseInputProps,\n ComboboxLikeProps<Value>,\n StylesApiProps<MultiSelectFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Controlled component value */\n value?: Value[];\n\n /** Uncontrolled component default value */\n defaultValue?: Value[];\n\n /** Called when value changes */\n onChange?: (value: Value[]) => void;\n\n /** Called with `value` of the removed item */\n onRemove?: (value: Value) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Called when user attemps to select more values than allowed */\n onMaxValues?: () => 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 values, no limit if not set */\n maxValues?: number;\n\n /** Allows searching through options by user input @default false */\n searchable?: boolean;\n\n /** Message displayed when no options match the search query (when searchable is enabled) or when the data array is empty. If not set, the dropdown will be hidden instead. */\n nothingFoundMessage?: React.ReactNode;\n\n /** If set, the check icon is displayed near the selected option label @default true */\n withCheckIcon?: boolean;\n\n /** If set, unchecked labels are aligned with checked ones @default false */\n withAlignedLabels?: boolean;\n\n /** Position of the checkmark icon shown next to selected options in the dropdown @default 'left' */\n checkIconPosition?: 'left' | 'right';\n\n /** When enabled, selected options are hidden from the dropdown list @default false */\n hidePickedOptions?: boolean;\n\n /** When enabled, displays a clear button to remove all selected values (hidden when component is empty, disabled, or read-only) @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?: (item: ComboboxLikeRenderOptionInput<ComboboxItem<Value>>) => React.ReactNode;\n\n /** A function to render content of the pill */\n renderPill?: (props: ComboboxRenderPillInput<Value>) => 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 */\n chevronColor?: MantineColor;\n\n /** Clear search value when item is selected @default true */\n clearSearchOnChange?: boolean;\n\n /** Controls whether dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n}\n\nexport type MultiSelectFactory = Factory<{\n props: MultiSelectProps;\n ref: HTMLInputElement;\n stylesNames: MultiSelectStylesNames;\n signature: <Value extends Primitive = string>(\n props: MultiSelectProps<Value>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n maxValues: Infinity,\n withCheckIcon: true,\n checkIconPosition: 'left',\n hiddenInputValuesDivider: ',',\n clearSearchOnChange: true,\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<MultiSelectProps>;\n\nexport const MultiSelect = genericFactory<MultiSelectFactory>((_props) => {\n const props = useProps('MultiSelect', 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 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 onFocus,\n onBlur,\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 labelProps,\n descriptionProps,\n errorProps,\n wrapperProps,\n description,\n label,\n error,\n maxValues,\n searchable,\n nothingFoundMessage,\n withCheckIcon,\n withAlignedLabels,\n checkIconPosition,\n hidePickedOptions,\n withErrorStyles,\n name,\n form,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n placeholder,\n hiddenInputValuesDivider,\n required,\n mod,\n renderOption,\n renderPill,\n onRemove,\n onClear,\n onMaxValues,\n scrollAreaProps,\n chevronColor,\n attributes,\n clearSearchOnChange,\n openOnFocus,\n loading,\n loadingPosition,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n const retainedSelectedOptions = useRef<Record<string, ComboboxItem<Primitive>>>({});\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<MultiSelectFactory>({\n name: 'MultiSelect',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<MultiSelectFactory>({\n props,\n styles,\n classNames,\n });\n\n const handleInputKeydown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.key === ' ' && !searchable) {\n event.preventDefault();\n combobox.toggleDropdown();\n }\n\n if (event.key === 'Backspace' && _searchValue.length === 0 && _value.length > 0) {\n onRemove?.(_value[_value.length - 1]);\n setValue(_value.slice(0, _value.length - 1));\n }\n };\n\n const values = _value.map((item, index) => {\n const optionData = optionsLockup[`${item}`] || retainedSelectedOptions.current[`${item}`];\n\n if (renderPill) {\n return (\n <Fragment key={`${item}-${index}`}>\n {renderPill({\n option: optionData,\n value: item,\n onRemove: () => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n },\n disabled,\n })}\n </Fragment>\n );\n }\n\n return (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly && !optionsLockup[`${item}`]?.disabled}\n onRemove={() => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n }}\n unstyled={unstyled}\n disabled={disabled}\n {...getStyles('pill')}\n >\n {optionData?.label || item}\n </Pill>\n );\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _searchValue]);\n\n useEffect(() => {\n _value.forEach((val) => {\n if (`${val}` in optionsLockup) {\n retainedSelectedOptions.current[`${val}`] = optionsLockup[`${val}`];\n }\n });\n }, [optionsLockup, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n setValue([]);\n handleSearchChange('');\n }}\n />\n );\n\n const filteredData = filterPickedValues({ data: parsedData, value: _value });\n const _clearable = clearable && _value.length > 0 && !disabled && !readOnly;\n const pillsListStyle = _clearable\n ? { paddingInlineEnd: clearSectionOffset[size] ?? clearSectionOffset.sm }\n : undefined;\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=\"MultiSelect\"\n attributes={attributes}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val as any);\n if (clearSearchOnChange) {\n handleSearchChange('');\n }\n combobox.updateSelectedOptionIndex('selected');\n\n if (_value.includes(optionsLockup[`${val}`].value as any)) {\n setValue(_value.filter((v) => v !== optionsLockup[`${val}`].value));\n onRemove?.(optionsLockup[`${val}`].value as any);\n } else if (_value.length < maxValues) {\n setValue([..._value, optionsLockup[`${val}`].value] as any);\n } else {\n onMaxValues?.();\n }\n }}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"MultiSelect\"\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 __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 rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n loading={loading}\n loadingPosition={loadingPosition}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\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={{\n ...props,\n rightSectionPointerEvents: rightSectionPointerEvents || 'none',\n multiline: true,\n }}\n pointer={!searchable}\n onClick={() => (searchable ? combobox.openDropdown() : combobox.toggleDropdown())}\n data-expanded={combobox.dropdownOpened || undefined}\n id={_id}\n required={required}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group\n attributes={attributes}\n disabled={disabled}\n unstyled={unstyled}\n {...getStyles('pillsList', { style: pillsListStyle })}\n >\n {values}\n <Combobox.EventsTarget autoComplete={autoComplete} withExpandedAttribute>\n <PillsInput.Field\n {...rest}\n id={_id}\n placeholder={placeholder}\n type={!searchable && !placeholder ? 'hidden' : 'visible'}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onFocus={(event) => {\n onFocus?.(event);\n openOnFocus && searchable && combobox.openDropdown();\n }}\n onBlur={(event) => {\n onBlur?.(event);\n combobox.closeDropdown();\n handleSearchChange('');\n }}\n onKeyDown={handleInputKeydown}\n value={_searchValue}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n searchable && combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n disabled={disabled}\n readOnly={readOnly || !searchable}\n pointer={!searchable}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n\n <OptionsDropdown\n data={hidePickedOptions ? filteredData : parsedData}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_searchValue}\n limit={limit}\n hiddenWhenEmpty={!nothingFoundMessage}\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n filterOptions={searchable}\n value={_value}\n checkIconPosition={checkIconPosition}\n withCheckIcon={withCheckIcon}\n withAlignedLabels={withAlignedLabels}\n nothingFoundMessage={nothingFoundMessage}\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 valuesDivider={hiddenInputValuesDivider}\n value={_value}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nMultiSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nMultiSelect.displayName = '@mantine/core/MultiSelect';\n\nexport namespace MultiSelect {\n export type Props<Value extends Primitive = string> = MultiSelectProps<Value>;\n export type StylesNames = MultiSelectStylesNames;\n export type Factory = MultiSelectFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,qBAA6C;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AA2GD,MAAM,eAAe;CACnB,WAAW;CACX,eAAe;CACf,mBAAmB;CACnB,0BAA0B;CAC1B,qBAAqB;CACrB,aAAa;CACb,MAAM;CACP;AAED,MAAa,cAAc,gBAAoC,WAAW;CACxE,MAAM,QAAQ,SAAS,eAAe,cAAc,OAAO;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,OACA,cACA,UACA,WACA,SACA,MACA,gBACA,uBACA,gBACA,iBACA,2BACA,iCACA,gBACA,eACA,QACA,OACA,gBACA,mBACA,aACA,oBACA,gBACA,UACA,UACA,SACA,QACA,QACA,cACA,mBACA,2BACA,mBACA,aACA,kBACA,0BACA,kBACA,gBACA,mBACA,cACA,YACA,kBACA,YACA,cACA,aACA,OACA,OACA,WACA,YACA,qBACA,eACA,mBACA,mBACA,mBACA,iBACA,MACA,MACA,IACA,WACA,kBACA,kBACA,kBACA,aACA,0BACA,UACA,KACA,cACA,YACA,UACA,SACA,aACA,iBACA,cACA,YACA,qBACA,aACA,SACA,iBACA,GAAG,WACD;CAEJ,MAAM,MAAMA,QAAM,GAAG;CACrB,MAAM,aAAa,sBAAsB,KAAK;CAC9C,MAAM,gBAAgB,iBAAiB,WAAW;CAClD,MAAM,0BAA0B,OAAgD,EAAE,CAAC;CAEnF,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,GAAG,WAC7B,kBAAkB,OAAO;CAE7B,MAAM,CAAC,QAAQ,YAAY,gBAAgB;EACzC;EACA;EACA,YAAY,EAAE;EACd;EACD,CAA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AAY,OAAO;GACzB;GACG;GACjB,CAAA,CACO;KACX,oBAAC,SAAS,aAAV;EACQ;EACN,eAAe;EACf,OAAO;EACD;EACI;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,YAAY,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AACnE,YAAY,cAAc"}
1
+ {"version":3,"file":"MultiSelect.mjs","names":["useId"],"sources":["../../../src/components/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n genericFactory,\n MantineColor,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n Combobox,\n ComboboxItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n ComboboxRenderPillInput,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n usePillsReorder,\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 { filterPickedValues } from './filter-picked-values';\n\nconst clearSectionOffset: Record<string, number> = {\n xs: 41,\n sm: 50,\n md: 60,\n lg: 72,\n xl: 89,\n};\n\nexport type MultiSelectStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport interface MultiSelectProps<Value extends Primitive = string>\n extends\n BoxProps,\n __BaseInputProps,\n ComboboxLikeProps<Value>,\n StylesApiProps<MultiSelectFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Controlled component value */\n value?: Value[];\n\n /** Uncontrolled component default value */\n defaultValue?: Value[];\n\n /** Called when value changes */\n onChange?: (value: Value[]) => void;\n\n /** Called with `value` of the removed item */\n onRemove?: (value: Value) => void;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Called when user attemps to select more values than allowed */\n onMaxValues?: () => 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 values, no limit if not set */\n maxValues?: number;\n\n /** Allows searching through options by user input @default false */\n searchable?: boolean;\n\n /** Message displayed when no options match the search query (when searchable is enabled) or when the data array is empty. If not set, the dropdown will be hidden instead. */\n nothingFoundMessage?: React.ReactNode;\n\n /** If set, the check icon is displayed near the selected option label @default true */\n withCheckIcon?: boolean;\n\n /** If set, unchecked labels are aligned with checked ones @default false */\n withAlignedLabels?: boolean;\n\n /** Position of the checkmark icon shown next to selected options in the dropdown @default 'left' */\n checkIconPosition?: 'left' | 'right';\n\n /** When enabled, selected options are hidden from the dropdown list @default false */\n hidePickedOptions?: boolean;\n\n /** When enabled, displays a clear button to remove all selected values (hidden when component is empty, disabled, or read-only) @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?: (item: ComboboxLikeRenderOptionInput<ComboboxItem<Value>>) => React.ReactNode;\n\n /** A function to render content of the pill */\n renderPill?: (props: ComboboxRenderPillInput<Value>) => 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 */\n chevronColor?: MantineColor;\n\n /** Clear search value when item is selected @default true */\n clearSearchOnChange?: boolean;\n\n /** Controls whether dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n\n /** If set, selected values can be reordered by dragging pills. Disabled when `disabled` or `readOnly` is set. @default false */\n withPillsReorder?: boolean;\n}\n\nexport type MultiSelectFactory = Factory<{\n props: MultiSelectProps;\n ref: HTMLInputElement;\n stylesNames: MultiSelectStylesNames;\n signature: <Value extends Primitive = string>(\n props: MultiSelectProps<Value>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n maxValues: Infinity,\n withCheckIcon: true,\n checkIconPosition: 'left',\n hiddenInputValuesDivider: ',',\n clearSearchOnChange: true,\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<MultiSelectProps>;\n\nexport const MultiSelect = genericFactory<MultiSelectFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'MultiSelect'], 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 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 onFocus,\n onBlur,\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 labelProps,\n descriptionProps,\n errorProps,\n wrapperProps,\n description,\n label,\n error,\n maxValues,\n searchable,\n nothingFoundMessage,\n withCheckIcon,\n withAlignedLabels,\n checkIconPosition,\n hidePickedOptions,\n withErrorStyles,\n name,\n form,\n id,\n clearable,\n clearSectionMode,\n clearButtonProps,\n hiddenInputProps,\n placeholder,\n hiddenInputValuesDivider,\n required,\n mod,\n renderOption,\n renderPill,\n onRemove,\n onClear,\n onMaxValues,\n scrollAreaProps,\n chevronColor,\n attributes,\n clearSearchOnChange,\n openOnFocus,\n loading,\n loadingPosition,\n withPillsReorder,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n const retainedSelectedOptions = useRef<Record<string, ComboboxItem<Primitive>>>({});\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 { getPillProps, getListProps, handleInputKeyDown } = usePillsReorder({\n value: _value,\n onChange: setValue,\n enabled: withPillsReorder && !disabled && !readOnly,\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<MultiSelectFactory>({\n name: 'MultiSelect',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<MultiSelectFactory>({\n props,\n styles,\n classNames,\n });\n\n const handleInputKeydown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === ' ' && !searchable) {\n event.preventDefault();\n combobox.toggleDropdown();\n }\n\n if (event.key === 'Backspace' && _searchValue.length === 0 && _value.length > 0) {\n onRemove?.(_value[_value.length - 1]);\n setValue(_value.slice(0, _value.length - 1));\n }\n\n handleInputKeyDown(event);\n };\n\n const values = _value.map((item, index) => {\n const optionData = optionsLockup[`${item}`] || retainedSelectedOptions.current[`${item}`];\n const reorderProps = getPillProps(index);\n\n if (renderPill) {\n return (\n <Fragment key={`${item}-${index}`}>\n {renderPill({\n option: optionData,\n value: item,\n onRemove: () => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n },\n disabled,\n reorderProps,\n })}\n </Fragment>\n );\n }\n\n return (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly && !optionsLockup[`${item}`]?.disabled}\n onRemove={() => {\n setValue(_value.filter((i) => item !== i));\n onRemove?.(item);\n }}\n unstyled={unstyled}\n disabled={disabled}\n {...getStyles('pill')}\n {...reorderProps}\n >\n {optionData?.label || item}\n </Pill>\n );\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _searchValue]);\n\n useEffect(() => {\n _value.forEach((val) => {\n if (`${val}` in optionsLockup) {\n retainedSelectedOptions.current[`${val}`] = optionsLockup[`${val}`];\n }\n });\n }, [optionsLockup, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n setValue([]);\n handleSearchChange('');\n }}\n />\n );\n\n const filteredData = filterPickedValues({ data: parsedData, value: _value });\n const _clearable = clearable && _value.length > 0 && !disabled && !readOnly;\n const pillsListStyle = _clearable\n ? { paddingInlineEnd: clearSectionOffset[size] ?? clearSectionOffset.sm }\n : undefined;\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=\"MultiSelect\"\n attributes={attributes}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val as any);\n if (clearSearchOnChange) {\n handleSearchChange('');\n }\n combobox.updateSelectedOptionIndex('selected');\n\n if (_value.includes(optionsLockup[`${val}`].value as any)) {\n setValue(_value.filter((v) => v !== optionsLockup[`${val}`].value));\n onRemove?.(optionsLockup[`${val}`].value as any);\n } else if (_value.length < maxValues) {\n setValue([..._value, optionsLockup[`${val}`].value] as any);\n } else {\n onMaxValues?.();\n }\n }}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"MultiSelect\"\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 __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 rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n loading={loading}\n loadingPosition={loadingPosition}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\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={{\n ...props,\n rightSectionPointerEvents: rightSectionPointerEvents || 'none',\n multiline: true,\n }}\n pointer={!searchable}\n onClick={() => (searchable ? combobox.openDropdown() : combobox.toggleDropdown())}\n data-expanded={combobox.dropdownOpened || undefined}\n id={_id}\n required={required}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group\n attributes={attributes}\n disabled={disabled}\n unstyled={unstyled}\n {...getStyles('pillsList', { style: pillsListStyle })}\n {...getListProps()}\n >\n {values}\n <Combobox.EventsTarget autoComplete={autoComplete} withExpandedAttribute>\n <PillsInput.Field\n {...rest}\n id={_id}\n placeholder={placeholder}\n type={!searchable && !placeholder ? 'hidden' : 'visible'}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onFocus={(event) => {\n onFocus?.(event);\n openOnFocus && searchable && combobox.openDropdown();\n }}\n onBlur={(event) => {\n onBlur?.(event);\n combobox.closeDropdown();\n handleSearchChange('');\n }}\n onKeyDown={handleInputKeydown}\n value={_searchValue}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n searchable && combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n disabled={disabled}\n readOnly={readOnly || !searchable}\n pointer={!searchable}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n\n <OptionsDropdown\n data={hidePickedOptions ? filteredData : parsedData}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_searchValue}\n limit={limit}\n hiddenWhenEmpty={!nothingFoundMessage}\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n filterOptions={searchable}\n value={_value}\n checkIconPosition={checkIconPosition}\n withCheckIcon={withCheckIcon}\n withAlignedLabels={withAlignedLabels}\n nothingFoundMessage={nothingFoundMessage}\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 valuesDivider={hiddenInputValuesDivider}\n value={_value}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nMultiSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nMultiSelect.displayName = '@mantine/core/MultiSelect';\n\nexport namespace MultiSelect {\n export type Props<Value extends Primitive = string> = MultiSelectProps<Value>;\n export type StylesNames = MultiSelectStylesNames;\n export type Factory = MultiSelectFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,qBAA6C;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AA8GD,MAAM,eAAe;CACnB,WAAW;CACX,eAAe;CACf,mBAAmB;CACnB,0BAA0B;CAC1B,qBAAqB;CACrB,aAAa;CACb,MAAM;CACP;AAED,MAAa,cAAc,gBAAoC,WAAW;CACxE,MAAM,QAAQ,SAAS;EAAC;EAAS;EAAgB;EAAc,EAAE,cAAc,OAAO;CACtF,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,OACA,cACA,UACA,WACA,SACA,MACA,gBACA,uBACA,gBACA,iBACA,2BACA,iCACA,gBACA,eACA,QACA,OACA,gBACA,mBACA,aACA,oBACA,gBACA,UACA,UACA,SACA,QACA,QACA,cACA,mBACA,2BACA,mBACA,aACA,kBACA,0BACA,kBACA,gBACA,mBACA,cACA,YACA,kBACA,YACA,cACA,aACA,OACA,OACA,WACA,YACA,qBACA,eACA,mBACA,mBACA,mBACA,iBACA,MACA,MACA,IACA,WACA,kBACA,kBACA,kBACA,aACA,0BACA,UACA,KACA,cACA,YACA,UACA,SACA,aACA,iBACA,cACA,YACA,qBACA,aACA,SACA,iBACA,kBACA,GAAG,WACD;CAEJ,MAAM,MAAMA,QAAM,GAAG;CACrB,MAAM,aAAa,sBAAsB,KAAK;CAC9C,MAAM,gBAAgB,iBAAiB,WAAW;CAClD,MAAM,0BAA0B,OAAgD,EAAE,CAAC;CAEnF,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,GAAG,WAC7B,kBAAkB,OAAO;CAE7B,MAAM,CAAC,QAAQ,YAAY,gBAAgB;EACzC;EACA;EACA,YAAY,EAAE;EACd;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A,EAE1B,oBAAC,iBAAD;GACE,MAAM,oBAAoB,eAAe;GACzC,QAAQ,YAAY;GACZ;GACR,QAAQ;GACD;GACP,iBAAiB,CAAC;GACF;GACG;GACnB,eAAe;GACf,OAAO;GACY;GACJ;GACI;GACE;GACX;GACV,SAAS,QAAQ,GAAG,IAAI,UAAU,KAAA;GAClC,cAAY,QAAQ,KAAA,IAAY,OAAO;GACzB;GACG;GACjB,CAAA,CACO;KACX,oBAAC,SAAS,aAAV;EACQ;EACN,eAAe;EACf,OAAO;EACD;EACI;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,YAAY,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AACnE,YAAY,cAAc"}
@@ -12,7 +12,11 @@ const defaultProps = {
12
12
  rightSectionPointerEvents: "none"
13
13
  };
14
14
  const NativeSelect = factory((props) => {
15
- const { data, children, size, error, rightSection, unstyled, ...others } = useProps("NativeSelect", defaultProps, props);
15
+ const { data, children, size, error, rightSection, unstyled, ...others } = useProps([
16
+ "Input",
17
+ "InputWrapper",
18
+ "NativeSelect"
19
+ ], defaultProps, props);
16
20
  const options = getParsedComboboxData(data).map((item, index) => /* @__PURE__ */ jsx(NativeSelectOption, { data: item }, index));
17
21
  return /* @__PURE__ */ jsx(InputBase, {
18
22
  component: "select",
@@ -1 +1 @@
1
- {"version":3,"file":"NativeSelect.mjs","names":[],"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 '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;CAC5B;AAED,MAAa,eAAe,SAA8B,UAAU;CAClE,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,cAAc,UAAU,GAAG,WAAW,SACzE,gBACA,cACA,MACD;CAED,MAAM,UAAU,sBAA8B,KAAK,CAAC,KAAK,MAAM,UAC7D,oBAAC,oBAAD,EAAgC,MAAM,MAAQ,EAArB,MAAqB,CAC9C;AAEF,QACE,oBAAC,WAAD;EACE,WAAU;EACV,GAAI;EACJ,kBAAiB;EACX;EACN,SAAA;EACO;EACG;EACV,cACE,gBAAgB,oBAAC,iBAAD;GAAuB;GAAa;GAAiB;GAAY,CAAA;YAGlF,YAAY;EACH,CAAA;EAEd;AAEF,aAAa,UAAU,UAAU;AACjC,aAAa,cAAc"}
1
+ {"version":3,"file":"NativeSelect.mjs","names":[],"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;CAC5B;AAED,MAAa,eAAe,SAA8B,UAAU;CAClE,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,cAAc,UAAU,GAAG,WAAW,SACzE;EAAC;EAAS;EAAgB;EAAe,EACzC,cACA,MACD;CAED,MAAM,UAAU,sBAA8B,KAAK,CAAC,KAAK,MAAM,UAC7D,oBAAC,oBAAD,EAAgC,MAAM,MAAQ,EAArB,MAAqB,CAC9C;AAEF,QACE,oBAAC,WAAD;EACE,WAAU;EACV,GAAI;EACJ,kBAAiB;EACX;EACN,SAAA;EACO;EACG;EACV,cACE,gBAAgB,oBAAC,iBAAD;GAAuB;GAAa;GAAiB;GAAY,CAAA;YAGlF,YAAY;EACH,CAAA;EAEd;AAEF,aAAa,UAAU,UAAU;AACjC,aAAa,cAAc"}
@@ -98,7 +98,11 @@ function clampAndSanitizeBigIntInput(sanitizedValue, options) {
98
98
  return options.clampBehavior === "blur" ? clampBigInt(parsed, options.min, options.max) : parsed;
99
99
  }
100
100
  const NumberInput = genericFactory((_props) => {
101
- const props = useProps("NumberInput", defaultProps, _props);
101
+ const props = useProps([
102
+ "Input",
103
+ "InputWrapper",
104
+ "NumberInput"
105
+ ], defaultProps, _props);
102
106
  const { className, classNames, styles, unstyled, vars, onChange, onValueChange, value, defaultValue, max, min, step, hideControls, rightSection, isAllowed, clampBehavior, onBlur, allowDecimal, decimalScale, onKeyDown, onKeyDownCapture, handlersRef, startValue, disabled, rightSectionPointerEvents, allowNegative, readOnly, size, rightSectionWidth, stepHoldInterval, stepHoldDelay, allowLeadingZeros, withKeyboardEvents, trimLeadingZeroesOnBlur, allowedDecimalSeparators, selectAllOnFocus, onMinReached, onMaxReached, onFocus, attributes, ref, ...others } = props;
103
107
  const allowNegativeResolved = allowNegative ?? true;
104
108
  const allowLeadingZerosResolved = allowLeadingZeros ?? true;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.mjs","names":["classes"],"sources":["../../../src/components/NumberInput/NumberInput.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport cx from 'clsx';\nimport { NumberFormatValues, NumericFormat, OnValueChange } from 'react-number-format';\nimport { assignRef, clamp, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n Factory,\n genericFactory,\n getSize,\n noop,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { __BaseInputProps, __InputStylesNames, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { UnstyledButton } from '../UnstyledButton';\nimport { NumberInputChevron } from './NumberInputChevron';\nimport classes from './NumberInput.module.css';\n\n// Re for negative -0, -0., -0.0, -0.00, -0.000 ... strings\n// And for positive 0., 0.0, 0.00, 0.000 ... strings\nconst leadingDecimalZeroPattern = /^(0\\.0*|-0(\\.0*)?)$/;\n\n// Re for 01, 006, 00.02, -0010, -000.293 ... and negative counterparts\nconst leadingZerosPattern = /^-?0\\d+(\\.\\d+)?\\.?$/;\n\n// Re for decimal numbers with trailing zeros like 13.0, 13.00, 5.10 ... strings\nconst trailingZerosPattern = /\\.\\d*0$/;\n\n// Re for numbers with trailing decimal separator like 10. or -3.\nconst trailingDecimalSeparatorPattern = /^-?\\d+\\.$/;\n\nexport interface NumberInputHandlers {\n increment: () => void;\n decrement: () => void;\n}\n\nexport type NumberInputMode = 'number' | 'bigint';\nexport type NumberInputNumericType = number | bigint;\nexport type NumberInputValue<T extends NumberInputNumericType = number> = T | string;\ntype NumberInputNumericValue<T extends NumberInputNumericType = number> = T;\ntype InternalNumberInputValue = string | number | bigint;\n\nfunction isNumberString(value: unknown) {\n return typeof value === 'string' && value !== '' && !Number.isNaN(Number(value));\n}\n\nfunction isBigIntValue(value: unknown): value is bigint {\n return typeof value === 'bigint';\n}\n\nfunction canStep(value: number | string) {\n if (typeof value === 'number') {\n return value < Number.MAX_SAFE_INTEGER;\n }\n\n return value === '' || (isNumberString(value) && Number(value) < Number.MAX_SAFE_INTEGER);\n}\n\nfunction isValidBigIntString(value: string, allowNegative: boolean) {\n if (value === '') {\n return false;\n }\n\n if (value === '-') {\n return false;\n }\n\n if (!allowNegative && value.startsWith('-')) {\n return false;\n }\n\n return /^-?\\d+$/.test(value);\n}\n\nfunction canStepBigInt(value: bigint | string, allowNegative: boolean) {\n if (typeof value === 'bigint') {\n return true;\n }\n\n return value === '' || isValidBigIntString(value, allowNegative);\n}\n\nfunction parseBigIntFromString(value: string): bigint | null {\n if (!/^-?\\d+$/.test(value)) {\n return null;\n }\n\n try {\n return BigInt(value);\n } catch {\n return null;\n }\n}\n\nfunction toBigIntOrUndefined(value: unknown): bigint | undefined {\n if (typeof value === 'bigint') {\n return value;\n }\n\n if (typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value)) {\n return BigInt(value);\n }\n\n return undefined;\n}\n\nfunction clampBigInt(value: bigint, min?: bigint, max?: bigint) {\n if (min !== undefined && value < min) {\n return min;\n }\n\n if (max !== undefined && value > max) {\n return max;\n }\n\n return value;\n}\n\nfunction getTotalDigits(inputValue: string | number): number {\n // All digits must be counted, parseFloat precision depends\n // on the number of digits in the input, not only on the decimal scale\n return inputValue.toString().replace('.', '').length;\n}\n\nfunction isValidNumber(floatValue: number | undefined, value: string): floatValue is number {\n return (\n (typeof floatValue === 'number'\n ? floatValue < Number.MAX_SAFE_INTEGER\n : !Number.isNaN(Number(floatValue))) &&\n !Number.isNaN(floatValue) &&\n getTotalDigits(value) < 14 &&\n value !== ''\n );\n}\n\nfunction isInRange(value: number | undefined, min: number | undefined, max: number | undefined) {\n if (value === undefined) {\n return true;\n }\n\n const minValid = min === undefined || value >= min;\n const maxValid = max === undefined || value <= max;\n\n return minValid && maxValid;\n}\n\nexport type NumberInputStylesNames = 'controls' | 'control' | __InputStylesNames;\nexport type NumberInputCssVariables = {\n controls: '--ni-chevron-size';\n};\n\nexport interface NumberInputProps<T extends NumberInputNumericType = number>\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<NumberInputFactory>,\n ElementProps<\n 'input',\n 'size' | 'type' | 'onChange' | 'value' | 'defaultValue' | 'min' | 'max' | 'step'\n > {\n /** Controlled component value */\n value?: NumberInputValue<T>;\n\n /** Uncontrolled component default value */\n defaultValue?: NumberInputValue<T>;\n\n /** Called when value changes */\n onChange?: (value: NumberInputValue<T>) => void;\n\n /** Called when value changes with `react-number-format` payload */\n onValueChange?: OnValueChange;\n\n /** Determines whether leading zeros are allowed during input. If `false`, leading zeros are removed as you type (e.g., typing `007` results in `7`). Works in conjunction with `trimLeadingZeroesOnBlur`. @default true */\n allowLeadingZeros?: boolean;\n\n /** Determines whether negative numbers are allowed. If `false`, the input will not accept negative values, and the decrement button will stop at `0` (when `min` is not set). @default true */\n allowNegative?: boolean;\n\n /** Characters which when pressed result in a decimal separator. These characters will be replaced by the `decimalSeparator` in the input value. @default ['.', ','] */\n allowedDecimalSeparators?: string[];\n\n /** Limits the number of digits that can be entered after the decimal point @default Infinity */\n decimalScale?: number;\n\n /** Character used as a decimal separator. Generally used with `allowedDecimalSeparators` prop. @default '.' */\n decimalSeparator?: string;\n\n /** If `true`, automatically pads the decimal part with zeros to match `decimalScale` (e.g., with `decimalScale={2}`, typing `5.1` displays as `5.10`). Requires `decimalScale` to be set. @default false */\n fixedDecimalScale?: boolean;\n\n /** Prefix added before the input value */\n prefix?: string;\n\n /** Suffix added after the input value */\n suffix?: string;\n\n /** Defines the thousand grouping style. 'thousand' (1,000), 'lakh' (1,00,000), 'wan' (1,0000), 'none'. */\n thousandsGroupStyle?: 'thousand' | 'lakh' | 'wan' | 'none';\n\n /** A function to validate the input value. If this function returns `false`, the `onChange` will not be called and the input value will not change. */\n isAllowed?: (values: NumberFormatValues) => boolean;\n\n /** Advanced: Set to `true` if you're passing numeric strings (e.g., `\"12345\"`) and using formatting props like `prefix` or `suffix`. In most cases, you don't need this prop. See [react-number-format docs](https://www.npmjs.com/package/react-number-format) for details. @default false */\n valueIsNumericString?: boolean;\n\n /** Controls input `type` attribute @default 'text' */\n type?: 'text' | 'tel' | 'password';\n\n /** A character used to separate thousands */\n thousandSeparator?: string | boolean;\n\n /** Minimum possible value */\n min?: NumberInputNumericValue<T>;\n\n /** Maximum possible value */\n max?: NumberInputNumericValue<T>;\n\n /** Number by which value will be incremented/decremented with up/down controls and keyboard arrows @default 1 */\n step?: NumberInputNumericValue<T>;\n\n /** If set, the up/down controls are hidden @default false */\n hideControls?: boolean;\n\n /** Controls how values are clamped to the `min`/`max` range:\n * - `'blur'` (default): User can type any value, but it's clamped when the input loses focus\n * - `'strict'`: User cannot type values outside the range\n * - `'none'`: No clamping; `min`/`max` only apply to increment/decrement controls and arrow keys\n */\n clampBehavior?: 'strict' | 'blur' | 'none';\n\n /** If set, decimal values are allowed @default true */\n allowDecimal?: boolean;\n\n /** Increment/decrement handlers */\n handlersRef?: React.Ref<NumberInputHandlers | undefined>;\n\n /** Value used when incrementing/decrementing an empty input. If `min` is set and `startValue < min`, `min` is used instead. @default 0 */\n startValue?: NumberInputNumericValue<T>;\n\n /** Interval in milliseconds between value steps when increment/decrement button is held down. Can be a number or a function `(stepCount) => number` for dynamic intervals. Requires `stepHoldDelay` to be set. @default undefined */\n stepHoldInterval?: number | ((stepCount: number) => number);\n\n /** Initial delay in milliseconds before stepping the value. */\n stepHoldDelay?: number;\n\n /** If set, up/down keyboard events increment/decrement value @default true */\n withKeyboardEvents?: boolean;\n\n /** If set, leading zeros are removed on blur. For example, `00100` -> `100` @default true */\n trimLeadingZeroesOnBlur?: boolean;\n\n /** If set, all text is selected when the input receives focus @default false */\n selectAllOnFocus?: boolean;\n\n /** Called when the increment button or arrow up key is pressed and the value has reached the maximum */\n onMinReached?: () => void;\n\n /** Called when the decrement button or arrow down key is pressed and the value has reached the minimum */\n onMaxReached?: () => void;\n}\n\nexport type NumberInputFactory = Factory<{\n props: NumberInputProps;\n ref: HTMLInputElement;\n stylesNames: NumberInputStylesNames;\n vars: NumberInputCssVariables;\n variant: InputVariant;\n signature: <T extends NumberInputNumericType = number>(\n props: NumberInputProps<T>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n step: 1,\n clampBehavior: 'blur',\n allowDecimal: true,\n allowNegative: true,\n withKeyboardEvents: true,\n allowLeadingZeros: true,\n trimLeadingZeroesOnBlur: true,\n startValue: 0,\n allowedDecimalSeparators: ['.', ','],\n} satisfies Partial<NumberInputProps<number | bigint>>;\n\nconst varsResolver = createVarsResolver<NumberInputFactory>((_, { size }) => ({\n controls: {\n '--ni-chevron-size': getSize(size, 'ni-chevron-size'),\n },\n}));\n\nfunction clampAndSanitizeInput(sanitizedValue: string | number, max?: number, min?: number) {\n const stringValue = sanitizedValue.toString();\n const hasTrailingDecimalSeparator = trailingDecimalSeparatorPattern.test(stringValue);\n\n const replaced = stringValue.replace(/^0+(?=\\d)/, '');\n const parsedValue = parseFloat(replaced);\n\n if (Number.isNaN(parsedValue)) {\n return replaced;\n }\n\n if (parsedValue > Number.MAX_SAFE_INTEGER) {\n return max !== undefined ? max : replaced;\n }\n\n const clamped = clamp(parsedValue, min, max);\n\n if (hasTrailingDecimalSeparator) {\n const clampedString = clamped.toString().replace(/^0+(?=\\d)/, '');\n return `${clampedString}.`;\n }\n\n return clamped;\n}\n\nfunction clampAndSanitizeBigIntInput(\n sanitizedValue: string,\n options: { min?: bigint; max?: bigint; clampBehavior: NumberInputProps['clampBehavior'] }\n) {\n if (sanitizedValue === '' || sanitizedValue === '-') {\n return sanitizedValue;\n }\n\n const parsed = parseBigIntFromString(sanitizedValue);\n\n if (parsed === null) {\n return sanitizedValue;\n }\n\n return options.clampBehavior === 'blur' ? clampBigInt(parsed, options.min, options.max) : parsed;\n}\n\nexport const NumberInput = genericFactory<NumberInputFactory>(\n <T extends NumberInputNumericType = number>(_props: NumberInputProps<T>) => {\n const props = useProps(\n 'NumberInput',\n defaultProps as Partial<NumberInputProps>,\n _props as unknown as NumberInputProps\n );\n const {\n className,\n classNames,\n styles,\n unstyled,\n vars,\n onChange,\n onValueChange,\n value,\n defaultValue,\n max,\n min,\n step,\n hideControls,\n rightSection,\n isAllowed,\n clampBehavior,\n onBlur,\n allowDecimal,\n decimalScale,\n onKeyDown,\n onKeyDownCapture,\n handlersRef,\n startValue,\n disabled,\n rightSectionPointerEvents,\n allowNegative,\n readOnly,\n size,\n rightSectionWidth,\n stepHoldInterval,\n stepHoldDelay,\n allowLeadingZeros,\n withKeyboardEvents,\n trimLeadingZeroesOnBlur,\n allowedDecimalSeparators,\n selectAllOnFocus,\n onMinReached,\n onMaxReached,\n onFocus,\n attributes,\n ref,\n ...others\n } = props;\n const allowNegativeResolved = allowNegative ?? true;\n const allowLeadingZerosResolved = allowLeadingZeros ?? true;\n\n const getStyles = useStyles<NumberInputFactory>({\n name: 'NumberInput',\n classes,\n props: props as NumberInputProps,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<NumberInputFactory>({\n classNames,\n styles,\n props: props as NumberInputProps,\n });\n\n const valueModeRef = useRef<NumberInputMode>(\n isBigIntValue(value) || isBigIntValue(defaultValue) ? 'bigint' : 'number'\n );\n\n if (isBigIntValue(value)) {\n valueModeRef.current = 'bigint';\n } else if (typeof value === 'number') {\n valueModeRef.current = 'number';\n }\n\n const isBigIntMode = valueModeRef.current === 'bigint';\n\n const [_value, setValue] = useUncontrolled<InternalNumberInputValue>({\n value: value as InternalNumberInputValue | undefined,\n defaultValue: defaultValue as InternalNumberInputValue | undefined,\n finalValue: '',\n onChange: onChange as ((value: InternalNumberInputValue) => void) | undefined,\n });\n\n const shouldUseStepInterval = stepHoldDelay !== undefined && stepHoldInterval !== undefined;\n const inputRef = useRef<HTMLInputElement>(null);\n const onStepTimeoutRef = useRef<number | null>(null);\n const stepCountRef = useRef<number>(0);\n\n const minNumber = typeof min === 'number' ? min : undefined;\n const maxNumber = typeof max === 'number' ? max : undefined;\n const stepNumber = typeof step === 'number' ? step : defaultProps.step;\n const startValueNumber = typeof startValue === 'number' ? startValue : defaultProps.startValue;\n\n const minBigInt = toBigIntOrUndefined(min);\n const maxBigInt = toBigIntOrUndefined(max);\n const stepBigInt = toBigIntOrUndefined(step) ?? BigInt(1);\n const startValueBigInt = toBigIntOrUndefined(startValue) ?? BigInt(0);\n\n const parseBigIntOrString = (inputValue: string): bigint | string => {\n if (\n !isValidBigIntString(inputValue, allowNegativeResolved) ||\n (allowLeadingZerosResolved && leadingZerosPattern.test(inputValue))\n ) {\n return inputValue;\n }\n\n const parsed = parseBigIntFromString(inputValue);\n return parsed ?? inputValue;\n };\n\n const getBigIntFloatValue = (inputValue: bigint) => {\n const numericValue = Number(inputValue);\n return Number.isSafeInteger(numericValue) ? numericValue : undefined;\n };\n\n const handleValueChange: OnValueChange = (payload, event) => {\n if (event.source === 'event') {\n if (isBigIntMode) {\n setValue(parseBigIntOrString(payload.value));\n } else {\n setValue(\n isValidNumber(payload.floatValue, payload.value) &&\n !leadingDecimalZeroPattern.test(payload.value) &&\n !(allowLeadingZerosResolved ? leadingZerosPattern.test(payload.value) : false) &&\n !trailingZerosPattern.test(payload.value) &&\n !trailingDecimalSeparatorPattern.test(payload.value)\n ? payload.floatValue\n : payload.value\n );\n }\n }\n onValueChange?.(payload, event);\n };\n\n const getDecimalPlaces = (inputValue: number | string): number => {\n const match = String(inputValue).match(/(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/);\n if (!match) {\n return 0;\n }\n return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));\n };\n\n const adjustCursor = (position?: number) => {\n if (inputRef.current && typeof position !== 'undefined') {\n inputRef.current.setSelectionRange(position, position);\n }\n };\n\n const incrementRef = useRef<() => void>(noop);\n incrementRef.current = () => {\n if (isBigIntMode) {\n if (!canStepBigInt(_value as bigint | string, allowNegativeResolved)) {\n return;\n }\n\n let val: bigint;\n const currentValue = _value;\n\n if (typeof currentValue === 'bigint') {\n const incrementedValue = currentValue + stepBigInt;\n if (maxBigInt !== undefined && incrementedValue > maxBigInt) {\n onMaxReached?.();\n }\n val =\n maxBigInt !== undefined && incrementedValue > maxBigInt ? maxBigInt : incrementedValue;\n } else if (typeof currentValue === 'string' && currentValue !== '') {\n const parsed = parseBigIntFromString(currentValue);\n if (parsed === null) {\n return;\n }\n\n const incrementedValue = parsed + stepBigInt;\n if (maxBigInt !== undefined && incrementedValue > maxBigInt) {\n onMaxReached?.();\n }\n val =\n maxBigInt !== undefined && incrementedValue > maxBigInt ? maxBigInt : incrementedValue;\n } else {\n val = clampBigInt(startValueBigInt, minBigInt, maxBigInt);\n }\n\n const formattedValue = val.toString();\n setValue(val);\n onValueChange?.(\n { floatValue: getBigIntFloatValue(val), formattedValue, value: formattedValue },\n { source: 'increment' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n return;\n }\n\n if (!canStep(_value as number | string)) {\n return;\n }\n\n let val: number;\n const currentValuePrecision = getDecimalPlaces(_value as number | string);\n const stepPrecision = getDecimalPlaces(stepNumber);\n const maxPrecision = Math.max(currentValuePrecision, stepPrecision);\n const factor = 10 ** maxPrecision;\n\n if (!isNumberString(_value) && (typeof _value !== 'number' || Number.isNaN(_value))) {\n val = clamp(startValueNumber, minNumber, maxNumber);\n } else if (maxNumber !== undefined) {\n const incrementedValue =\n (Math.round(Number(_value) * factor) + Math.round(stepNumber * factor)) / factor;\n if (incrementedValue > maxNumber) {\n onMaxReached?.();\n }\n val = incrementedValue <= maxNumber ? incrementedValue : maxNumber;\n } else {\n val = (Math.round(Number(_value) * factor) + Math.round(stepNumber * factor)) / factor;\n }\n\n const formattedValue = val.toFixed(maxPrecision);\n setValue(parseFloat(formattedValue));\n onValueChange?.(\n { floatValue: parseFloat(formattedValue), formattedValue, value: formattedValue },\n { source: 'increment' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n };\n\n const decrementRef = useRef<() => void>(noop);\n decrementRef.current = () => {\n if (isBigIntMode) {\n if (!canStepBigInt(_value as bigint | string, allowNegativeResolved)) {\n return;\n }\n\n let val: bigint;\n const minValue =\n minBigInt !== undefined ? minBigInt : !allowNegativeResolved ? BigInt(0) : undefined;\n const currentValue = _value;\n\n if (typeof currentValue === 'bigint') {\n const decrementedValue = currentValue - stepBigInt;\n if (minValue !== undefined && decrementedValue < minValue) {\n onMinReached?.();\n }\n val = minValue !== undefined && decrementedValue < minValue ? minValue : decrementedValue;\n } else if (typeof currentValue === 'string' && currentValue !== '') {\n const parsed = parseBigIntFromString(currentValue);\n if (parsed === null) {\n return;\n }\n\n const decrementedValue = parsed - stepBigInt;\n if (minValue !== undefined && decrementedValue < minValue) {\n onMinReached?.();\n }\n val = minValue !== undefined && decrementedValue < minValue ? minValue : decrementedValue;\n } else {\n val = clampBigInt(startValueBigInt, minValue, maxBigInt);\n }\n\n const formattedValue = val.toString();\n setValue(val);\n onValueChange?.(\n { floatValue: getBigIntFloatValue(val), formattedValue, value: formattedValue },\n { source: 'decrement' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n return;\n }\n\n if (!canStep(_value as number | string)) {\n return;\n }\n\n let val: number;\n const minValue =\n minNumber !== undefined ? minNumber : !allowNegativeResolved ? 0 : Number.MIN_SAFE_INTEGER;\n const currentValuePrecision = getDecimalPlaces(_value as number | string);\n const stepPrecision = getDecimalPlaces(stepNumber);\n const maxPrecision = Math.max(currentValuePrecision, stepPrecision);\n const factor = 10 ** maxPrecision;\n\n if ((!isNumberString(_value) && typeof _value !== 'number') || Number.isNaN(_value)) {\n val = clamp(startValueNumber, minValue, maxNumber);\n } else {\n const decrementedValue =\n (Math.round(Number(_value) * factor) - Math.round(stepNumber * factor)) / factor;\n if (minValue !== undefined && decrementedValue < minValue) {\n onMinReached?.();\n }\n val = minValue !== undefined && decrementedValue < minValue ? minValue : decrementedValue;\n }\n\n const formattedValue = val.toFixed(maxPrecision);\n setValue(parseFloat(formattedValue));\n onValueChange?.(\n { floatValue: parseFloat(formattedValue), formattedValue, value: formattedValue },\n { source: 'decrement' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n const pastedText = event.clipboardData.getData('text');\n const _decimalSeparator = others.decimalSeparator || '.';\n const separatorsToReplace = (allowedDecimalSeparators || ['.', ',']).filter(\n (s) => s !== _decimalSeparator\n );\n\n if (separatorsToReplace.some((s) => pastedText.includes(s))) {\n event.preventDefault();\n let modifiedText = pastedText;\n separatorsToReplace.forEach((s) => {\n modifiedText = modifiedText.split(s).join(_decimalSeparator);\n });\n\n const input = inputRef.current;\n if (input) {\n const start = input.selectionStart ?? 0;\n const end = input.selectionEnd ?? 0;\n const currentValue = input.value;\n const newValue =\n currentValue.substring(0, start) + modifiedText + currentValue.substring(end);\n\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n 'value'\n )?.set;\n nativeInputValueSetter?.call(input, newValue);\n input.dispatchEvent(new Event('change', { bubbles: true }));\n\n const cursorPos = start + modifiedText.length;\n setTimeout(() => adjustCursor(cursorPos), 0);\n }\n }\n\n others.onPaste?.(event as any);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (readOnly || !withKeyboardEvents) {\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n incrementRef.current?.();\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n decrementRef.current?.();\n }\n };\n\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDownCapture?.(event);\n if (event.key === 'Backspace') {\n const input = inputRef.current;\n if (input && input.selectionStart === 0 && input.selectionStart === input.selectionEnd) {\n event.preventDefault();\n window.setTimeout(() => adjustCursor(0), 0);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (selectAllOnFocus) {\n setTimeout(() => event.currentTarget.select(), 0);\n }\n onFocus?.(event);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n let sanitizedValue = _value;\n\n if (isBigIntMode) {\n if (clampBehavior === 'blur' && typeof sanitizedValue === 'bigint') {\n sanitizedValue = clampBigInt(sanitizedValue, minBigInt, maxBigInt);\n }\n\n if (trimLeadingZeroesOnBlur && typeof sanitizedValue === 'string') {\n sanitizedValue = clampAndSanitizeBigIntInput(sanitizedValue, {\n min: minBigInt,\n max: maxBigInt,\n clampBehavior,\n });\n }\n } else {\n if (clampBehavior === 'blur' && typeof sanitizedValue === 'number') {\n sanitizedValue = clamp(sanitizedValue, minNumber, maxNumber);\n }\n\n if (\n trimLeadingZeroesOnBlur &&\n typeof sanitizedValue === 'string' &&\n getDecimalPlaces(sanitizedValue) < 15\n ) {\n sanitizedValue = clampAndSanitizeInput(sanitizedValue, maxNumber, minNumber);\n }\n }\n\n if (_value !== sanitizedValue) {\n setValue(sanitizedValue);\n }\n\n onBlur?.(event);\n };\n\n assignRef(handlersRef, { increment: incrementRef.current, decrement: decrementRef.current });\n\n const onStepHandleChange = (isIncrement: boolean) => {\n if (isIncrement) {\n incrementRef.current?.();\n } else {\n decrementRef.current?.();\n }\n stepCountRef.current += 1;\n };\n\n const onStepLoop = (isIncrement: boolean) => {\n onStepHandleChange(isIncrement);\n\n if (shouldUseStepInterval) {\n const interval =\n typeof stepHoldInterval === 'number'\n ? stepHoldInterval\n : stepHoldInterval(stepCountRef.current);\n onStepTimeoutRef.current = window.setTimeout(() => onStepLoop(isIncrement), interval);\n }\n };\n\n const onStep = (\n event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n isIncrement: boolean\n ) => {\n event.preventDefault();\n inputRef.current?.focus();\n onStepHandleChange(isIncrement);\n if (shouldUseStepInterval) {\n onStepTimeoutRef.current = window.setTimeout(() => onStepLoop(isIncrement), stepHoldDelay);\n }\n };\n\n const onStepDone = () => {\n if (onStepTimeoutRef.current) {\n window.clearTimeout(onStepTimeoutRef.current);\n }\n onStepTimeoutRef.current = null;\n stepCountRef.current = 0;\n };\n\n const controls = (\n <div {...getStyles('controls')}>\n <UnstyledButton\n {...getStyles('control')}\n tabIndex={-1}\n aria-hidden\n disabled={\n disabled ||\n (typeof _value === 'number' && maxNumber !== undefined && _value >= maxNumber) ||\n (typeof _value === 'bigint' && maxBigInt !== undefined && _value >= maxBigInt)\n }\n mod={{ direction: 'up' }}\n onMouseDown={(event) => event.preventDefault()}\n onPointerDown={(event) => {\n onStep(event, true);\n }}\n onPointerUp={onStepDone}\n onPointerLeave={onStepDone}\n >\n <NumberInputChevron direction=\"up\" />\n </UnstyledButton>\n <UnstyledButton\n {...getStyles('control')}\n tabIndex={-1}\n aria-hidden\n disabled={\n disabled ||\n (typeof _value === 'number' && minNumber !== undefined && _value <= minNumber) ||\n (typeof _value === 'bigint' && minBigInt !== undefined && _value <= minBigInt)\n }\n mod={{ direction: 'down' }}\n onMouseDown={(event) => event.preventDefault()}\n onPointerDown={(event) => {\n onStep(event, false);\n }}\n onPointerUp={onStepDone}\n onPointerLeave={onStepDone}\n >\n <NumberInputChevron direction=\"down\" />\n </UnstyledButton>\n </div>\n );\n\n return (\n <InputBase\n component={NumericFormat}\n allowNegative={allowNegative}\n className={cx(classes.root, className)}\n size={size}\n {...others}\n inputMode={isBigIntMode ? 'numeric' : 'decimal'}\n readOnly={readOnly}\n disabled={disabled}\n value={typeof _value === 'bigint' ? _value.toString() : _value}\n getInputRef={useMergedRef(ref, inputRef)}\n onValueChange={handleValueChange}\n rightSection={\n hideControls ||\n readOnly ||\n !(isBigIntMode\n ? canStepBigInt(_value as bigint | string, allowNegativeResolved)\n : canStep(_value as number | string))\n ? rightSection\n : rightSection || controls\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n __staticSelector=\"NumberInput\"\n decimalScale={isBigIntMode ? 0 : allowDecimal ? decimalScale : 0}\n onPaste={handlePaste}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={handleKeyDownCapture}\n rightSectionPointerEvents={rightSectionPointerEvents ?? (disabled ? 'none' : undefined)}\n rightSectionWidth={rightSectionWidth ?? `var(--ni-right-section-width-${size || 'sm'})`}\n allowLeadingZeros={allowLeadingZeros}\n allowedDecimalSeparators={allowedDecimalSeparators}\n onBlur={handleBlur}\n attributes={attributes}\n isAllowed={(val) => {\n const userAllowed = isAllowed ? isAllowed(val) : true;\n if (!userAllowed) {\n return false;\n }\n\n if (clampBehavior !== 'strict') {\n return true;\n }\n\n if (!isBigIntMode) {\n return isInRange(val.floatValue, minNumber, maxNumber);\n }\n\n if (val.value === '' || val.value === '-') {\n return true;\n }\n\n const parsed = parseBigIntFromString(val.value);\n\n if (parsed === null) {\n return true;\n }\n\n return (\n (minBigInt === undefined || parsed >= minBigInt) &&\n (maxBigInt === undefined || parsed <= maxBigInt)\n );\n }}\n />\n );\n }\n);\n\nNumberInput.classes = { ...InputBase.classes, ...classes };\nNumberInput.varsResolver = varsResolver;\nNumberInput.displayName = '@mantine/core/NumberInput';\n\nexport namespace NumberInput {\n export type Props<T extends NumberInputNumericType = number> = NumberInputProps<T>;\n export type StylesNames = NumberInputStylesNames;\n export type Factory = NumberInputFactory;\n export type CssVariables = NumberInputCssVariables;\n export type Handlers = NumberInputHandlers;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,MAAM,4BAA4B;AAGlC,MAAM,sBAAsB;AAG5B,MAAM,uBAAuB;AAG7B,MAAM,kCAAkC;AAaxC,SAAS,eAAe,OAAgB;AACtC,QAAO,OAAO,UAAU,YAAY,UAAU,MAAM,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC;;AAGlF,SAAS,cAAc,OAAiC;AACtD,QAAO,OAAO,UAAU;;AAG1B,SAAS,QAAQ,OAAwB;AACvC,KAAI,OAAO,UAAU,SACnB,QAAO,QAAQ,OAAO;AAGxB,QAAO,UAAU,MAAO,eAAe,MAAM,IAAI,OAAO,MAAM,GAAG,OAAO;;AAG1E,SAAS,oBAAoB,OAAe,eAAwB;AAClE,KAAI,UAAU,GACZ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UAAU,GAAG;EACxD,aAAa,aAAa,KAAK,SAAS;EACxC,eAAe;EACf,cACE,gBACA,YACA,EAAE,eACE,cAAc,QAA2B,sBAAsB,GAC/D,QAAQ,OAA0B,IAClC,eACA,gBAAgB;EAEtB,YAAY;EACZ,QAAQ;EACE;EACV,kBAAiB;EACjB,cAAc,eAAe,IAAI,eAAe,eAAe;EAC/D,SAAS;EACT,SAAS;EACT,WAAW;EACX,kBAAkB;EAClB,2BAA2B,8BAA8B,WAAW,SAAS,KAAA;EAC7E,mBAAmB,qBAAqB,gCAAgC,QAAQ,KAAK;EAClE;EACO;EAC1B,QAAQ;EACI;EACZ,YAAY,QAAQ;AAElB,OAAI,EADgB,YAAY,UAAU,IAAI,GAAG,MAE/C,QAAO;AAGT,OAAI,kBAAkB,SACpB,QAAO;AAGT,OAAI,CAAC,aACH,QAAO,UAAU,IAAI,YAAY,WAAW,UAAU;AAGxD,OAAI,IAAI,UAAU,MAAM,IAAI,UAAU,IACpC,QAAO;GAGT,MAAM,SAAS,sBAAsB,IAAI,MAAM;AAE/C,OAAI,WAAW,KACb,QAAO;AAGT,WACG,cAAc,KAAA,KAAa,UAAU,eACrC,cAAc,KAAA,KAAa,UAAU;;EAG1C,CAAA;EAGP;AAED,YAAY,UAAU;CAAE,GAAG,UAAU;CAAS,GAAGA;CAAS;AAC1D,YAAY,eAAe;AAC3B,YAAY,cAAc"}
1
+ {"version":3,"file":"NumberInput.mjs","names":["classes"],"sources":["../../../src/components/NumberInput/NumberInput.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport cx from 'clsx';\nimport { NumberFormatValues, NumericFormat, OnValueChange } from 'react-number-format';\nimport { assignRef, clamp, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n Factory,\n genericFactory,\n getSize,\n noop,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { __BaseInputProps, __InputStylesNames, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { UnstyledButton } from '../UnstyledButton';\nimport { NumberInputChevron } from './NumberInputChevron';\nimport classes from './NumberInput.module.css';\n\n// Re for negative -0, -0., -0.0, -0.00, -0.000 ... strings\n// And for positive 0., 0.0, 0.00, 0.000 ... strings\nconst leadingDecimalZeroPattern = /^(0\\.0*|-0(\\.0*)?)$/;\n\n// Re for 01, 006, 00.02, -0010, -000.293 ... and negative counterparts\nconst leadingZerosPattern = /^-?0\\d+(\\.\\d+)?\\.?$/;\n\n// Re for decimal numbers with trailing zeros like 13.0, 13.00, 5.10 ... strings\nconst trailingZerosPattern = /\\.\\d*0$/;\n\n// Re for numbers with trailing decimal separator like 10. or -3.\nconst trailingDecimalSeparatorPattern = /^-?\\d+\\.$/;\n\nexport interface NumberInputHandlers {\n increment: () => void;\n decrement: () => void;\n}\n\nexport type NumberInputMode = 'number' | 'bigint';\nexport type NumberInputNumericType = number | bigint;\nexport type NumberInputValue<T extends NumberInputNumericType = number> = T | string;\ntype NumberInputNumericValue<T extends NumberInputNumericType = number> = T;\ntype InternalNumberInputValue = string | number | bigint;\n\nfunction isNumberString(value: unknown) {\n return typeof value === 'string' && value !== '' && !Number.isNaN(Number(value));\n}\n\nfunction isBigIntValue(value: unknown): value is bigint {\n return typeof value === 'bigint';\n}\n\nfunction canStep(value: number | string) {\n if (typeof value === 'number') {\n return value < Number.MAX_SAFE_INTEGER;\n }\n\n return value === '' || (isNumberString(value) && Number(value) < Number.MAX_SAFE_INTEGER);\n}\n\nfunction isValidBigIntString(value: string, allowNegative: boolean) {\n if (value === '') {\n return false;\n }\n\n if (value === '-') {\n return false;\n }\n\n if (!allowNegative && value.startsWith('-')) {\n return false;\n }\n\n return /^-?\\d+$/.test(value);\n}\n\nfunction canStepBigInt(value: bigint | string, allowNegative: boolean) {\n if (typeof value === 'bigint') {\n return true;\n }\n\n return value === '' || isValidBigIntString(value, allowNegative);\n}\n\nfunction parseBigIntFromString(value: string): bigint | null {\n if (!/^-?\\d+$/.test(value)) {\n return null;\n }\n\n try {\n return BigInt(value);\n } catch {\n return null;\n }\n}\n\nfunction toBigIntOrUndefined(value: unknown): bigint | undefined {\n if (typeof value === 'bigint') {\n return value;\n }\n\n if (typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value)) {\n return BigInt(value);\n }\n\n return undefined;\n}\n\nfunction clampBigInt(value: bigint, min?: bigint, max?: bigint) {\n if (min !== undefined && value < min) {\n return min;\n }\n\n if (max !== undefined && value > max) {\n return max;\n }\n\n return value;\n}\n\nfunction getTotalDigits(inputValue: string | number): number {\n // All digits must be counted, parseFloat precision depends\n // on the number of digits in the input, not only on the decimal scale\n return inputValue.toString().replace('.', '').length;\n}\n\nfunction isValidNumber(floatValue: number | undefined, value: string): floatValue is number {\n return (\n (typeof floatValue === 'number'\n ? floatValue < Number.MAX_SAFE_INTEGER\n : !Number.isNaN(Number(floatValue))) &&\n !Number.isNaN(floatValue) &&\n getTotalDigits(value) < 14 &&\n value !== ''\n );\n}\n\nfunction isInRange(value: number | undefined, min: number | undefined, max: number | undefined) {\n if (value === undefined) {\n return true;\n }\n\n const minValid = min === undefined || value >= min;\n const maxValid = max === undefined || value <= max;\n\n return minValid && maxValid;\n}\n\nexport type NumberInputStylesNames = 'controls' | 'control' | __InputStylesNames;\nexport type NumberInputCssVariables = {\n controls: '--ni-chevron-size';\n};\n\nexport interface NumberInputProps<T extends NumberInputNumericType = number>\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<NumberInputFactory>,\n ElementProps<\n 'input',\n 'size' | 'type' | 'onChange' | 'value' | 'defaultValue' | 'min' | 'max' | 'step'\n > {\n /** Controlled component value */\n value?: NumberInputValue<T>;\n\n /** Uncontrolled component default value */\n defaultValue?: NumberInputValue<T>;\n\n /** Called when value changes */\n onChange?: (value: NumberInputValue<T>) => void;\n\n /** Called when value changes with `react-number-format` payload */\n onValueChange?: OnValueChange;\n\n /** Determines whether leading zeros are allowed during input. If `false`, leading zeros are removed as you type (e.g., typing `007` results in `7`). Works in conjunction with `trimLeadingZeroesOnBlur`. @default true */\n allowLeadingZeros?: boolean;\n\n /** Determines whether negative numbers are allowed. If `false`, the input will not accept negative values, and the decrement button will stop at `0` (when `min` is not set). @default true */\n allowNegative?: boolean;\n\n /** Characters which when pressed result in a decimal separator. These characters will be replaced by the `decimalSeparator` in the input value. @default ['.', ','] */\n allowedDecimalSeparators?: string[];\n\n /** Limits the number of digits that can be entered after the decimal point @default Infinity */\n decimalScale?: number;\n\n /** Character used as a decimal separator. Generally used with `allowedDecimalSeparators` prop. @default '.' */\n decimalSeparator?: string;\n\n /** If `true`, automatically pads the decimal part with zeros to match `decimalScale` (e.g., with `decimalScale={2}`, typing `5.1` displays as `5.10`). Requires `decimalScale` to be set. @default false */\n fixedDecimalScale?: boolean;\n\n /** Prefix added before the input value */\n prefix?: string;\n\n /** Suffix added after the input value */\n suffix?: string;\n\n /** Defines the thousand grouping style. 'thousand' (1,000), 'lakh' (1,00,000), 'wan' (1,0000), 'none'. */\n thousandsGroupStyle?: 'thousand' | 'lakh' | 'wan' | 'none';\n\n /** A function to validate the input value. If this function returns `false`, the `onChange` will not be called and the input value will not change. */\n isAllowed?: (values: NumberFormatValues) => boolean;\n\n /** Advanced: Set to `true` if you're passing numeric strings (e.g., `\"12345\"`) and using formatting props like `prefix` or `suffix`. In most cases, you don't need this prop. See [react-number-format docs](https://www.npmjs.com/package/react-number-format) for details. @default false */\n valueIsNumericString?: boolean;\n\n /** Controls input `type` attribute @default 'text' */\n type?: 'text' | 'tel' | 'password';\n\n /** A character used to separate thousands */\n thousandSeparator?: string | boolean;\n\n /** Minimum possible value */\n min?: NumberInputNumericValue<T>;\n\n /** Maximum possible value */\n max?: NumberInputNumericValue<T>;\n\n /** Number by which value will be incremented/decremented with up/down controls and keyboard arrows @default 1 */\n step?: NumberInputNumericValue<T>;\n\n /** If set, the up/down controls are hidden @default false */\n hideControls?: boolean;\n\n /** Controls how values are clamped to the `min`/`max` range:\n * - `'blur'` (default): User can type any value, but it's clamped when the input loses focus\n * - `'strict'`: User cannot type values outside the range\n * - `'none'`: No clamping; `min`/`max` only apply to increment/decrement controls and arrow keys\n */\n clampBehavior?: 'strict' | 'blur' | 'none';\n\n /** If set, decimal values are allowed @default true */\n allowDecimal?: boolean;\n\n /** Increment/decrement handlers */\n handlersRef?: React.Ref<NumberInputHandlers | undefined>;\n\n /** Value used when incrementing/decrementing an empty input. If `min` is set and `startValue < min`, `min` is used instead. @default 0 */\n startValue?: NumberInputNumericValue<T>;\n\n /** Interval in milliseconds between value steps when increment/decrement button is held down. Can be a number or a function `(stepCount) => number` for dynamic intervals. Requires `stepHoldDelay` to be set. @default undefined */\n stepHoldInterval?: number | ((stepCount: number) => number);\n\n /** Initial delay in milliseconds before stepping the value. */\n stepHoldDelay?: number;\n\n /** If set, up/down keyboard events increment/decrement value @default true */\n withKeyboardEvents?: boolean;\n\n /** If set, leading zeros are removed on blur. For example, `00100` -> `100` @default true */\n trimLeadingZeroesOnBlur?: boolean;\n\n /** If set, all text is selected when the input receives focus @default false */\n selectAllOnFocus?: boolean;\n\n /** Called when the increment button or arrow up key is pressed and the value has reached the maximum */\n onMinReached?: () => void;\n\n /** Called when the decrement button or arrow down key is pressed and the value has reached the minimum */\n onMaxReached?: () => void;\n}\n\nexport type NumberInputFactory = Factory<{\n props: NumberInputProps;\n ref: HTMLInputElement;\n stylesNames: NumberInputStylesNames;\n vars: NumberInputCssVariables;\n variant: InputVariant;\n signature: <T extends NumberInputNumericType = number>(\n props: NumberInputProps<T>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n step: 1,\n clampBehavior: 'blur',\n allowDecimal: true,\n allowNegative: true,\n withKeyboardEvents: true,\n allowLeadingZeros: true,\n trimLeadingZeroesOnBlur: true,\n startValue: 0,\n allowedDecimalSeparators: ['.', ','],\n} satisfies Partial<NumberInputProps<number | bigint>>;\n\nconst varsResolver = createVarsResolver<NumberInputFactory>((_, { size }) => ({\n controls: {\n '--ni-chevron-size': getSize(size, 'ni-chevron-size'),\n },\n}));\n\nfunction clampAndSanitizeInput(sanitizedValue: string | number, max?: number, min?: number) {\n const stringValue = sanitizedValue.toString();\n const hasTrailingDecimalSeparator = trailingDecimalSeparatorPattern.test(stringValue);\n\n const replaced = stringValue.replace(/^0+(?=\\d)/, '');\n const parsedValue = parseFloat(replaced);\n\n if (Number.isNaN(parsedValue)) {\n return replaced;\n }\n\n if (parsedValue > Number.MAX_SAFE_INTEGER) {\n return max !== undefined ? max : replaced;\n }\n\n const clamped = clamp(parsedValue, min, max);\n\n if (hasTrailingDecimalSeparator) {\n const clampedString = clamped.toString().replace(/^0+(?=\\d)/, '');\n return `${clampedString}.`;\n }\n\n return clamped;\n}\n\nfunction clampAndSanitizeBigIntInput(\n sanitizedValue: string,\n options: { min?: bigint; max?: bigint; clampBehavior: NumberInputProps['clampBehavior'] }\n) {\n if (sanitizedValue === '' || sanitizedValue === '-') {\n return sanitizedValue;\n }\n\n const parsed = parseBigIntFromString(sanitizedValue);\n\n if (parsed === null) {\n return sanitizedValue;\n }\n\n return options.clampBehavior === 'blur' ? clampBigInt(parsed, options.min, options.max) : parsed;\n}\n\nexport const NumberInput = genericFactory<NumberInputFactory>(\n <T extends NumberInputNumericType = number>(_props: NumberInputProps<T>) => {\n const props = useProps(\n ['Input', 'InputWrapper', 'NumberInput'],\n defaultProps as Partial<NumberInputProps>,\n _props as unknown as NumberInputProps\n );\n const {\n className,\n classNames,\n styles,\n unstyled,\n vars,\n onChange,\n onValueChange,\n value,\n defaultValue,\n max,\n min,\n step,\n hideControls,\n rightSection,\n isAllowed,\n clampBehavior,\n onBlur,\n allowDecimal,\n decimalScale,\n onKeyDown,\n onKeyDownCapture,\n handlersRef,\n startValue,\n disabled,\n rightSectionPointerEvents,\n allowNegative,\n readOnly,\n size,\n rightSectionWidth,\n stepHoldInterval,\n stepHoldDelay,\n allowLeadingZeros,\n withKeyboardEvents,\n trimLeadingZeroesOnBlur,\n allowedDecimalSeparators,\n selectAllOnFocus,\n onMinReached,\n onMaxReached,\n onFocus,\n attributes,\n ref,\n ...others\n } = props;\n const allowNegativeResolved = allowNegative ?? true;\n const allowLeadingZerosResolved = allowLeadingZeros ?? true;\n\n const getStyles = useStyles<NumberInputFactory>({\n name: 'NumberInput',\n classes,\n props: props as NumberInputProps,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<NumberInputFactory>({\n classNames,\n styles,\n props: props as NumberInputProps,\n });\n\n const valueModeRef = useRef<NumberInputMode>(\n isBigIntValue(value) || isBigIntValue(defaultValue) ? 'bigint' : 'number'\n );\n\n if (isBigIntValue(value)) {\n valueModeRef.current = 'bigint';\n } else if (typeof value === 'number') {\n valueModeRef.current = 'number';\n }\n\n const isBigIntMode = valueModeRef.current === 'bigint';\n\n const [_value, setValue] = useUncontrolled<InternalNumberInputValue>({\n value: value as InternalNumberInputValue | undefined,\n defaultValue: defaultValue as InternalNumberInputValue | undefined,\n finalValue: '',\n onChange: onChange as ((value: InternalNumberInputValue) => void) | undefined,\n });\n\n const shouldUseStepInterval = stepHoldDelay !== undefined && stepHoldInterval !== undefined;\n const inputRef = useRef<HTMLInputElement>(null);\n const onStepTimeoutRef = useRef<number | null>(null);\n const stepCountRef = useRef<number>(0);\n\n const minNumber = typeof min === 'number' ? min : undefined;\n const maxNumber = typeof max === 'number' ? max : undefined;\n const stepNumber = typeof step === 'number' ? step : defaultProps.step;\n const startValueNumber = typeof startValue === 'number' ? startValue : defaultProps.startValue;\n\n const minBigInt = toBigIntOrUndefined(min);\n const maxBigInt = toBigIntOrUndefined(max);\n const stepBigInt = toBigIntOrUndefined(step) ?? BigInt(1);\n const startValueBigInt = toBigIntOrUndefined(startValue) ?? BigInt(0);\n\n const parseBigIntOrString = (inputValue: string): bigint | string => {\n if (\n !isValidBigIntString(inputValue, allowNegativeResolved) ||\n (allowLeadingZerosResolved && leadingZerosPattern.test(inputValue))\n ) {\n return inputValue;\n }\n\n const parsed = parseBigIntFromString(inputValue);\n return parsed ?? inputValue;\n };\n\n const getBigIntFloatValue = (inputValue: bigint) => {\n const numericValue = Number(inputValue);\n return Number.isSafeInteger(numericValue) ? numericValue : undefined;\n };\n\n const handleValueChange: OnValueChange = (payload, event) => {\n if (event.source === 'event') {\n if (isBigIntMode) {\n setValue(parseBigIntOrString(payload.value));\n } else {\n setValue(\n isValidNumber(payload.floatValue, payload.value) &&\n !leadingDecimalZeroPattern.test(payload.value) &&\n !(allowLeadingZerosResolved ? leadingZerosPattern.test(payload.value) : false) &&\n !trailingZerosPattern.test(payload.value) &&\n !trailingDecimalSeparatorPattern.test(payload.value)\n ? payload.floatValue\n : payload.value\n );\n }\n }\n onValueChange?.(payload, event);\n };\n\n const getDecimalPlaces = (inputValue: number | string): number => {\n const match = String(inputValue).match(/(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/);\n if (!match) {\n return 0;\n }\n return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));\n };\n\n const adjustCursor = (position?: number) => {\n if (inputRef.current && typeof position !== 'undefined') {\n inputRef.current.setSelectionRange(position, position);\n }\n };\n\n const incrementRef = useRef<() => void>(noop);\n incrementRef.current = () => {\n if (isBigIntMode) {\n if (!canStepBigInt(_value as bigint | string, allowNegativeResolved)) {\n return;\n }\n\n let val: bigint;\n const currentValue = _value;\n\n if (typeof currentValue === 'bigint') {\n const incrementedValue = currentValue + stepBigInt;\n if (maxBigInt !== undefined && incrementedValue > maxBigInt) {\n onMaxReached?.();\n }\n val =\n maxBigInt !== undefined && incrementedValue > maxBigInt ? maxBigInt : incrementedValue;\n } else if (typeof currentValue === 'string' && currentValue !== '') {\n const parsed = parseBigIntFromString(currentValue);\n if (parsed === null) {\n return;\n }\n\n const incrementedValue = parsed + stepBigInt;\n if (maxBigInt !== undefined && incrementedValue > maxBigInt) {\n onMaxReached?.();\n }\n val =\n maxBigInt !== undefined && incrementedValue > maxBigInt ? maxBigInt : incrementedValue;\n } else {\n val = clampBigInt(startValueBigInt, minBigInt, maxBigInt);\n }\n\n const formattedValue = val.toString();\n setValue(val);\n onValueChange?.(\n { floatValue: getBigIntFloatValue(val), formattedValue, value: formattedValue },\n { source: 'increment' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n return;\n }\n\n if (!canStep(_value as number | string)) {\n return;\n }\n\n let val: number;\n const currentValuePrecision = getDecimalPlaces(_value as number | string);\n const stepPrecision = getDecimalPlaces(stepNumber);\n const maxPrecision = Math.max(currentValuePrecision, stepPrecision);\n const factor = 10 ** maxPrecision;\n\n if (!isNumberString(_value) && (typeof _value !== 'number' || Number.isNaN(_value))) {\n val = clamp(startValueNumber, minNumber, maxNumber);\n } else if (maxNumber !== undefined) {\n const incrementedValue =\n (Math.round(Number(_value) * factor) + Math.round(stepNumber * factor)) / factor;\n if (incrementedValue > maxNumber) {\n onMaxReached?.();\n }\n val = incrementedValue <= maxNumber ? incrementedValue : maxNumber;\n } else {\n val = (Math.round(Number(_value) * factor) + Math.round(stepNumber * factor)) / factor;\n }\n\n const formattedValue = val.toFixed(maxPrecision);\n setValue(parseFloat(formattedValue));\n onValueChange?.(\n { floatValue: parseFloat(formattedValue), formattedValue, value: formattedValue },\n { source: 'increment' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n };\n\n const decrementRef = useRef<() => void>(noop);\n decrementRef.current = () => {\n if (isBigIntMode) {\n if (!canStepBigInt(_value as bigint | string, allowNegativeResolved)) {\n return;\n }\n\n let val: bigint;\n const minValue =\n minBigInt !== undefined ? minBigInt : !allowNegativeResolved ? BigInt(0) : undefined;\n const currentValue = _value;\n\n if (typeof currentValue === 'bigint') {\n const decrementedValue = currentValue - stepBigInt;\n if (minValue !== undefined && decrementedValue < minValue) {\n onMinReached?.();\n }\n val = minValue !== undefined && decrementedValue < minValue ? minValue : decrementedValue;\n } else if (typeof currentValue === 'string' && currentValue !== '') {\n const parsed = parseBigIntFromString(currentValue);\n if (parsed === null) {\n return;\n }\n\n const decrementedValue = parsed - stepBigInt;\n if (minValue !== undefined && decrementedValue < minValue) {\n onMinReached?.();\n }\n val = minValue !== undefined && decrementedValue < minValue ? minValue : decrementedValue;\n } else {\n val = clampBigInt(startValueBigInt, minValue, maxBigInt);\n }\n\n const formattedValue = val.toString();\n setValue(val);\n onValueChange?.(\n { floatValue: getBigIntFloatValue(val), formattedValue, value: formattedValue },\n { source: 'decrement' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n return;\n }\n\n if (!canStep(_value as number | string)) {\n return;\n }\n\n let val: number;\n const minValue =\n minNumber !== undefined ? minNumber : !allowNegativeResolved ? 0 : Number.MIN_SAFE_INTEGER;\n const currentValuePrecision = getDecimalPlaces(_value as number | string);\n const stepPrecision = getDecimalPlaces(stepNumber);\n const maxPrecision = Math.max(currentValuePrecision, stepPrecision);\n const factor = 10 ** maxPrecision;\n\n if ((!isNumberString(_value) && typeof _value !== 'number') || Number.isNaN(_value)) {\n val = clamp(startValueNumber, minValue, maxNumber);\n } else {\n const decrementedValue =\n (Math.round(Number(_value) * factor) - Math.round(stepNumber * factor)) / factor;\n if (minValue !== undefined && decrementedValue < minValue) {\n onMinReached?.();\n }\n val = minValue !== undefined && decrementedValue < minValue ? minValue : decrementedValue;\n }\n\n const formattedValue = val.toFixed(maxPrecision);\n setValue(parseFloat(formattedValue));\n onValueChange?.(\n { floatValue: parseFloat(formattedValue), formattedValue, value: formattedValue },\n { source: 'decrement' as any }\n );\n setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n const pastedText = event.clipboardData.getData('text');\n const _decimalSeparator = others.decimalSeparator || '.';\n const separatorsToReplace = (allowedDecimalSeparators || ['.', ',']).filter(\n (s) => s !== _decimalSeparator\n );\n\n if (separatorsToReplace.some((s) => pastedText.includes(s))) {\n event.preventDefault();\n let modifiedText = pastedText;\n separatorsToReplace.forEach((s) => {\n modifiedText = modifiedText.split(s).join(_decimalSeparator);\n });\n\n const input = inputRef.current;\n if (input) {\n const start = input.selectionStart ?? 0;\n const end = input.selectionEnd ?? 0;\n const currentValue = input.value;\n const newValue =\n currentValue.substring(0, start) + modifiedText + currentValue.substring(end);\n\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n 'value'\n )?.set;\n nativeInputValueSetter?.call(input, newValue);\n input.dispatchEvent(new Event('change', { bubbles: true }));\n\n const cursorPos = start + modifiedText.length;\n setTimeout(() => adjustCursor(cursorPos), 0);\n }\n }\n\n others.onPaste?.(event as any);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (readOnly || !withKeyboardEvents) {\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n incrementRef.current?.();\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n decrementRef.current?.();\n }\n };\n\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDownCapture?.(event);\n if (event.key === 'Backspace') {\n const input = inputRef.current;\n if (input && input.selectionStart === 0 && input.selectionStart === input.selectionEnd) {\n event.preventDefault();\n window.setTimeout(() => adjustCursor(0), 0);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (selectAllOnFocus) {\n setTimeout(() => event.currentTarget.select(), 0);\n }\n onFocus?.(event);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n let sanitizedValue = _value;\n\n if (isBigIntMode) {\n if (clampBehavior === 'blur' && typeof sanitizedValue === 'bigint') {\n sanitizedValue = clampBigInt(sanitizedValue, minBigInt, maxBigInt);\n }\n\n if (trimLeadingZeroesOnBlur && typeof sanitizedValue === 'string') {\n sanitizedValue = clampAndSanitizeBigIntInput(sanitizedValue, {\n min: minBigInt,\n max: maxBigInt,\n clampBehavior,\n });\n }\n } else {\n if (clampBehavior === 'blur' && typeof sanitizedValue === 'number') {\n sanitizedValue = clamp(sanitizedValue, minNumber, maxNumber);\n }\n\n if (\n trimLeadingZeroesOnBlur &&\n typeof sanitizedValue === 'string' &&\n getDecimalPlaces(sanitizedValue) < 15\n ) {\n sanitizedValue = clampAndSanitizeInput(sanitizedValue, maxNumber, minNumber);\n }\n }\n\n if (_value !== sanitizedValue) {\n setValue(sanitizedValue);\n }\n\n onBlur?.(event);\n };\n\n assignRef(handlersRef, { increment: incrementRef.current, decrement: decrementRef.current });\n\n const onStepHandleChange = (isIncrement: boolean) => {\n if (isIncrement) {\n incrementRef.current?.();\n } else {\n decrementRef.current?.();\n }\n stepCountRef.current += 1;\n };\n\n const onStepLoop = (isIncrement: boolean) => {\n onStepHandleChange(isIncrement);\n\n if (shouldUseStepInterval) {\n const interval =\n typeof stepHoldInterval === 'number'\n ? stepHoldInterval\n : stepHoldInterval(stepCountRef.current);\n onStepTimeoutRef.current = window.setTimeout(() => onStepLoop(isIncrement), interval);\n }\n };\n\n const onStep = (\n event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n isIncrement: boolean\n ) => {\n event.preventDefault();\n inputRef.current?.focus();\n onStepHandleChange(isIncrement);\n if (shouldUseStepInterval) {\n onStepTimeoutRef.current = window.setTimeout(() => onStepLoop(isIncrement), stepHoldDelay);\n }\n };\n\n const onStepDone = () => {\n if (onStepTimeoutRef.current) {\n window.clearTimeout(onStepTimeoutRef.current);\n }\n onStepTimeoutRef.current = null;\n stepCountRef.current = 0;\n };\n\n const controls = (\n <div {...getStyles('controls')}>\n <UnstyledButton\n {...getStyles('control')}\n tabIndex={-1}\n aria-hidden\n disabled={\n disabled ||\n (typeof _value === 'number' && maxNumber !== undefined && _value >= maxNumber) ||\n (typeof _value === 'bigint' && maxBigInt !== undefined && _value >= maxBigInt)\n }\n mod={{ direction: 'up' }}\n onMouseDown={(event) => event.preventDefault()}\n onPointerDown={(event) => {\n onStep(event, true);\n }}\n onPointerUp={onStepDone}\n onPointerLeave={onStepDone}\n >\n <NumberInputChevron direction=\"up\" />\n </UnstyledButton>\n <UnstyledButton\n {...getStyles('control')}\n tabIndex={-1}\n aria-hidden\n disabled={\n disabled ||\n (typeof _value === 'number' && minNumber !== undefined && _value <= minNumber) ||\n (typeof _value === 'bigint' && minBigInt !== undefined && _value <= minBigInt)\n }\n mod={{ direction: 'down' }}\n onMouseDown={(event) => event.preventDefault()}\n onPointerDown={(event) => {\n onStep(event, false);\n }}\n onPointerUp={onStepDone}\n onPointerLeave={onStepDone}\n >\n <NumberInputChevron direction=\"down\" />\n </UnstyledButton>\n </div>\n );\n\n return (\n <InputBase\n component={NumericFormat}\n allowNegative={allowNegative}\n className={cx(classes.root, className)}\n size={size}\n {...others}\n inputMode={isBigIntMode ? 'numeric' : 'decimal'}\n readOnly={readOnly}\n disabled={disabled}\n value={typeof _value === 'bigint' ? _value.toString() : _value}\n getInputRef={useMergedRef(ref, inputRef)}\n onValueChange={handleValueChange}\n rightSection={\n hideControls ||\n readOnly ||\n !(isBigIntMode\n ? canStepBigInt(_value as bigint | string, allowNegativeResolved)\n : canStep(_value as number | string))\n ? rightSection\n : rightSection || controls\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n __staticSelector=\"NumberInput\"\n decimalScale={isBigIntMode ? 0 : allowDecimal ? decimalScale : 0}\n onPaste={handlePaste}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={handleKeyDownCapture}\n rightSectionPointerEvents={rightSectionPointerEvents ?? (disabled ? 'none' : undefined)}\n rightSectionWidth={rightSectionWidth ?? `var(--ni-right-section-width-${size || 'sm'})`}\n allowLeadingZeros={allowLeadingZeros}\n allowedDecimalSeparators={allowedDecimalSeparators}\n onBlur={handleBlur}\n attributes={attributes}\n isAllowed={(val) => {\n const userAllowed = isAllowed ? isAllowed(val) : true;\n if (!userAllowed) {\n return false;\n }\n\n if (clampBehavior !== 'strict') {\n return true;\n }\n\n if (!isBigIntMode) {\n return isInRange(val.floatValue, minNumber, maxNumber);\n }\n\n if (val.value === '' || val.value === '-') {\n return true;\n }\n\n const parsed = parseBigIntFromString(val.value);\n\n if (parsed === null) {\n return true;\n }\n\n return (\n (minBigInt === undefined || parsed >= minBigInt) &&\n (maxBigInt === undefined || parsed <= maxBigInt)\n );\n }}\n />\n );\n }\n);\n\nNumberInput.classes = { ...InputBase.classes, ...classes };\nNumberInput.varsResolver = varsResolver;\nNumberInput.displayName = '@mantine/core/NumberInput';\n\nexport namespace NumberInput {\n export type Props<T extends NumberInputNumericType = number> = NumberInputProps<T>;\n export type StylesNames = NumberInputStylesNames;\n export type Factory = NumberInputFactory;\n export type CssVariables = NumberInputCssVariables;\n export type Handlers = NumberInputHandlers;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,MAAM,4BAA4B;AAGlC,MAAM,sBAAsB;AAG5B,MAAM,uBAAuB;AAG7B,MAAM,kCAAkC;AAaxC,SAAS,eAAe,OAAgB;AACtC,QAAO,OAAO,UAAU,YAAY,UAAU,MAAM,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC;;AAGlF,SAAS,cAAc,OAAiC;AACtD,QAAO,OAAO,UAAU;;AAG1B,SAAS,QAAQ,OAAwB;AACvC,KAAI,OAAO,UAAU,SACnB,QAAO,QAAQ,OAAO;AAGxB,QAAO,UAAU,MAAO,eAAe,MAAM,IAAI,OAAO,MAAM,GAAG,OAAO;;AAG1E,SAAS,oBAAoB,OAAe,eAAwB;AAClE,KAAI,UAAU,GACZ,QAAO;AAGT,KAAI,UAAU,IACZ,QAAO;AAGT,KAAI,CAAC,iBAAiB,MAAM,WAAW,IAAI,CACzC,QAAO;AAGT,QAAO,UAAU,KAAK,MAAM;;AAG9B,SAAS,cAAc,OAAwB,eAAwB;AACrE,KAAI,OAAO,UAAU,SACnB,QAAO;AAGT,QAAO,UAAU,MAAM,oBAAoB,OAAO,cAAc;;AAG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AAe,eAAe;EAC/D,SAAS;EACT,SAAS;EACT,WAAW;EACX,kBAAkB;EAClB,2BAA2B,8BAA8B,WAAW,SAAS,KAAA;EAC7E,mBAAmB,qBAAqB,gCAAgC,QAAQ,KAAK;EAClE;EACO;EAC1B,QAAQ;EACI;EACZ,YAAY,QAAQ;AAElB,OAAI,EADgB,YAAY,UAAU,IAAI,GAAG,MAE/C,QAAO;AAGT,OAAI,kBAAkB,SACpB,QAAO;AAGT,OAAI,CAAC,aACH,QAAO,UAAU,IAAI,YAAY,WAAW,UAAU;AAGxD,OAAI,IAAI,UAAU,MAAM,IAAI,UAAU,IACpC,QAAO;GAGT,MAAM,SAAS,sBAAsB,IAAI,MAAM;AAE/C,OAAI,WAAW,KACb,QAAO;AAGT,WACG,cAAc,KAAA,KAAa,UAAU,eACrC,cAAc,KAAA,KAAa,UAAU;;EAG1C,CAAA;EAGP;AAED,YAAY,UAAU;CAAE,GAAG,UAAU;CAAS,GAAGA;CAAS;AAC1D,YAAY,eAAe;AAC3B,YAAY,cAAc"}
@@ -24,7 +24,11 @@ const varsResolver = createVarsResolver((_, { size }) => ({ root: {
24
24
  "--psi-button-size": getSize(size, "psi-button-size")
25
25
  } }));
26
26
  const PasswordInput = factory((_props) => {
27
- const props = useProps("PasswordInput", defaultProps, _props);
27
+ const props = useProps([
28
+ "Input",
29
+ "InputWrapper",
30
+ "PasswordInput"
31
+ ], defaultProps, _props);
28
32
  const { classNames, className, style, styles, unstyled, vars, required, error, leftSection, disabled, id, variant, inputContainer, description, label, size, errorProps, descriptionProps, labelProps, withAsterisk, inputWrapperOrder, wrapperProps, radius, rightSection, rightSectionWidth, rightSectionPointerEvents, leftSectionWidth, visible, defaultVisible, onVisibilityChange, visibilityToggleIcon: VisibilityToggleIcon, visibilityToggleButtonProps, rightSectionProps, leftSectionProps, leftSectionPointerEvents, withErrorStyles, mod, attributes, ...others } = props;
29
33
  const uuid = useId(id);
30
34
  const [_visible, setVisibility] = useUncontrolled({
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordInput.mjs","names":["classes"],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["import cx from 'clsx';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport { __BaseInputProps, __InputStylesNames, Input, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PasswordToggleIcon } from './PasswordToggleIcon';\nimport classes from './PasswordInput.module.css';\n\nexport type PasswordInputStylesNames =\n | 'root'\n | 'visibilityToggle'\n | 'innerInput'\n | __InputStylesNames;\nexport type PasswordInputCssVariables = {\n root: '--psi-icon-size' | '--psi-button-size';\n};\n\nexport interface PasswordInputProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<PasswordInputFactory>,\n ElementProps<'input', 'size'> {\n /** A component to replace the visibility toggle icon */\n visibilityToggleIcon?: React.FC<{ reveal: boolean }>;\n\n /** Props passed down to the visibility toggle button */\n visibilityToggleButtonProps?: Record<string, any>;\n\n /** If set, the input value is visible */\n visible?: boolean;\n\n /** If set, the input value is visible by default */\n defaultVisible?: boolean;\n\n /** Called when visibility changes */\n onVisibilityChange?: (visible: boolean) => void;\n}\n\nexport type PasswordInputFactory = Factory<{\n props: PasswordInputProps;\n ref: HTMLInputElement;\n stylesNames: PasswordInputStylesNames;\n vars: PasswordInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n visibilityToggleIcon: PasswordToggleIcon,\n size: 'sm',\n} satisfies Partial<PasswordInputProps>;\n\nconst varsResolver = createVarsResolver<PasswordInputFactory>((_, { size }) => ({\n root: {\n '--psi-icon-size': getSize(size, 'psi-icon-size'),\n '--psi-button-size': getSize(size, 'psi-button-size'),\n },\n}));\n\nexport const PasswordInput = factory<PasswordInputFactory>((_props) => {\n const props = useProps('PasswordInput', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n required,\n error,\n leftSection,\n disabled,\n id,\n variant,\n inputContainer,\n description,\n label,\n size,\n errorProps,\n descriptionProps,\n labelProps,\n withAsterisk,\n inputWrapperOrder,\n wrapperProps,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n leftSectionWidth,\n visible,\n defaultVisible,\n onVisibilityChange,\n visibilityToggleIcon: VisibilityToggleIcon,\n visibilityToggleButtonProps,\n rightSectionProps,\n leftSectionProps,\n leftSectionPointerEvents,\n withErrorStyles,\n mod,\n attributes,\n ...others\n } = props;\n\n const uuid = useId(id);\n\n const [_visible, setVisibility] = useUncontrolled({\n value: visible,\n defaultValue: defaultVisible,\n finalValue: false,\n onChange: onVisibilityChange,\n });\n\n const toggleVisibility = () => setVisibility(!_visible);\n\n const getStyles = useStyles<PasswordInputFactory>({\n name: 'PasswordInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PasswordInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const errorId = errorProps?.id || `${uuid}-error`;\n const descriptionId = descriptionProps?.id || `${uuid}-description`;\n const hasError = !!error && typeof error !== 'boolean';\n const hasDescription = !!description;\n const _describedBy = `${hasError ? errorId : ''} ${hasDescription ? descriptionId : ''}`;\n const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : undefined;\n\n const visibilityToggleButton = (\n <ActionIcon<'button'>\n {...getStyles('visibilityToggle')}\n disabled={disabled}\n radius={radius}\n aria-pressed={_visible}\n tabIndex={-1}\n aria-label=\"Toggle password visibility\"\n {...visibilityToggleButtonProps}\n variant={visibilityToggleButtonProps?.variant ?? 'subtle'}\n color=\"gray\"\n unstyled={unstyled}\n onTouchEnd={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onTouchEnd?.(event);\n toggleVisibility();\n }}\n onMouseDown={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onMouseDown?.(event);\n toggleVisibility();\n }}\n onKeyDown={(event) => {\n visibilityToggleButtonProps?.onKeyDown?.(event);\n if (event.key === ' ') {\n event.preventDefault();\n toggleVisibility();\n }\n }}\n >\n <VisibilityToggleIcon reveal={_visible} />\n </ActionIcon>\n );\n\n return (\n <Input.Wrapper\n required={required}\n id={uuid}\n label={label}\n error={error}\n description={description}\n size={size}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n unstyled={unstyled}\n withAsterisk={withAsterisk}\n inputWrapperOrder={inputWrapperOrder}\n inputContainer={inputContainer}\n variant={variant}\n labelProps={{ ...labelProps, htmlFor: uuid }}\n descriptionProps={{ ...descriptionProps, id: descriptionId }}\n errorProps={{ ...errorProps, id: errorId }}\n mod={mod}\n attributes={attributes}\n {...getStyles('root')}\n {...styleProps}\n {...wrapperProps}\n >\n <Input\n component=\"div\"\n error={error}\n leftSection={leftSection}\n size={size}\n classNames={{ ...resolvedClassNames, input: cx(classes.input, resolvedClassNames?.input) }}\n styles={resolvedStyles}\n radius={radius}\n disabled={disabled}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n rightSectionWidth={rightSectionWidth}\n rightSection={rightSection ?? visibilityToggleButton}\n variant={variant}\n unstyled={unstyled}\n leftSectionWidth={leftSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents || 'all'}\n rightSectionProps={rightSectionProps}\n leftSectionProps={leftSectionProps}\n leftSectionPointerEvents={leftSectionPointerEvents}\n withAria={false}\n withErrorStyles={withErrorStyles}\n attributes={attributes}\n >\n <input\n required={required}\n data-invalid={!!error || undefined}\n data-with-left-section={!!leftSection || undefined}\n {...getStyles('innerInput')}\n disabled={disabled}\n id={uuid}\n {...rest}\n aria-describedby={describedBy}\n autoComplete={rest.autoComplete || 'off'}\n type={_visible ? 'text' : 'password'}\n />\n </Input>\n </Input.Wrapper>\n );\n});\n\nPasswordInput.classes = { ...InputBase.classes, ...classes };\nPasswordInput.varsResolver = varsResolver;\nPasswordInput.displayName = '@mantine/core/PasswordInput';\n\nexport namespace PasswordInput {\n export type Props = PasswordInputProps;\n export type StylesNames = PasswordInputStylesNames;\n export type CssVariables = PasswordInputCssVariables;\n export type Factory = PasswordInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4DA,MAAM,eAAe;CACnB,sBAAsB;CACtB,MAAM;CACP;AAED,MAAM,eAAe,oBAA0C,GAAG,EAAE,YAAY,EAC9E,MAAM;CACJ,mBAAmB,QAAQ,MAAM,gBAAgB;CACjD,qBAAqB,QAAQ,MAAM,kBAAkB;CACtD,EACF,EAAE;AAEH,MAAa,gBAAgB,SAA+B,WAAW;CACrE,MAAM,QAAQ,SAAS,iBAAiB,cAAc,OAAO;CAC7D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,OACA,aACA,UACA,IACA,SACA,gBACA,aACA,OACA,MACA,YACA,kBACA,YACA,cACA,mBACA,cACA,QACA,cACA,mBACA,2BACA,kBACA,SACA,gBACA,oBACA,sBAAsB,sBACtB,6BACA,mBACA,kBACA,0BACA,iBACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,OAAO,MAAM,GAAG;CAEtB,MAAM,CAAC,UAAU,iBAAiB,gBAAgB;EAChD,OAAO;EACP,cAAc;EACd,YAAY;EACZ,UAAU;EACX,CAAC;CAEF,MAAM,yBAAyB,cAAc,CAAC,SAAS;CAEvD,MAAM,YAAY,UAAgC;EAChD,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,oBAAoB,mBAAmB,qBAA2C;EACxF;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,YAAY,SAAS,kBAAkB,OAAO;CACtD,MAAM,UAAU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kBAAiB;GACjB,kBAAkB;GACC;GACnB,cAAc,gBAAgB;GACrB;GACC;GACQ;GAClB,2BAA2B,6BAA6B;GACrC;GACD;GACQ;GAC1B,UAAU;GACO;GACL;aAEZ,oBAAC,SAAD;IACY;IACV,gBAAc,CAAC,CAAC,SAAS,KAAA;IACzB,0BAAwB,CAAC,CAAC,eAAe,KAAA;IACzC,GAAI,UAAU,aAAa;IACjB;IACV,IAAI;IACJ,GAAI;IACJ,oBAAkB;IAClB,cAAc,KAAK,gBAAgB;IACnC,MAAM,WAAW,SAAS;IAC1B,CAAA;GACI,CAAA;EACM,CAAA;EAElB;AAEF,cAAc,UAAU;CAAE,GAAG,UAAU;CAAS,GAAGA;CAAS;AAC5D,cAAc,eAAe;AAC7B,cAAc,cAAc"}
1
+ {"version":3,"file":"PasswordInput.mjs","names":["classes"],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["import cx from 'clsx';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport { __BaseInputProps, __InputStylesNames, Input, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PasswordToggleIcon } from './PasswordToggleIcon';\nimport classes from './PasswordInput.module.css';\n\nexport type PasswordInputStylesNames =\n | 'root'\n | 'visibilityToggle'\n | 'innerInput'\n | __InputStylesNames;\nexport type PasswordInputCssVariables = {\n root: '--psi-icon-size' | '--psi-button-size';\n};\n\nexport interface PasswordInputProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<PasswordInputFactory>,\n ElementProps<'input', 'size'> {\n /** A component to replace the visibility toggle icon */\n visibilityToggleIcon?: React.FC<{ reveal: boolean }>;\n\n /** Props passed down to the visibility toggle button */\n visibilityToggleButtonProps?: Record<string, any>;\n\n /** If set, the input value is visible */\n visible?: boolean;\n\n /** If set, the input value is visible by default */\n defaultVisible?: boolean;\n\n /** Called when visibility changes */\n onVisibilityChange?: (visible: boolean) => void;\n}\n\nexport type PasswordInputFactory = Factory<{\n props: PasswordInputProps;\n ref: HTMLInputElement;\n stylesNames: PasswordInputStylesNames;\n vars: PasswordInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n visibilityToggleIcon: PasswordToggleIcon,\n size: 'sm',\n} satisfies Partial<PasswordInputProps>;\n\nconst varsResolver = createVarsResolver<PasswordInputFactory>((_, { size }) => ({\n root: {\n '--psi-icon-size': getSize(size, 'psi-icon-size'),\n '--psi-button-size': getSize(size, 'psi-button-size'),\n },\n}));\n\nexport const PasswordInput = factory<PasswordInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'PasswordInput'], defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n required,\n error,\n leftSection,\n disabled,\n id,\n variant,\n inputContainer,\n description,\n label,\n size,\n errorProps,\n descriptionProps,\n labelProps,\n withAsterisk,\n inputWrapperOrder,\n wrapperProps,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n leftSectionWidth,\n visible,\n defaultVisible,\n onVisibilityChange,\n visibilityToggleIcon: VisibilityToggleIcon,\n visibilityToggleButtonProps,\n rightSectionProps,\n leftSectionProps,\n leftSectionPointerEvents,\n withErrorStyles,\n mod,\n attributes,\n ...others\n } = props;\n\n const uuid = useId(id);\n\n const [_visible, setVisibility] = useUncontrolled({\n value: visible,\n defaultValue: defaultVisible,\n finalValue: false,\n onChange: onVisibilityChange,\n });\n\n const toggleVisibility = () => setVisibility(!_visible);\n\n const getStyles = useStyles<PasswordInputFactory>({\n name: 'PasswordInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PasswordInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const errorId = errorProps?.id || `${uuid}-error`;\n const descriptionId = descriptionProps?.id || `${uuid}-description`;\n const hasError = !!error && typeof error !== 'boolean';\n const hasDescription = !!description;\n const _describedBy = `${hasError ? errorId : ''} ${hasDescription ? descriptionId : ''}`;\n const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : undefined;\n\n const visibilityToggleButton = (\n <ActionIcon<'button'>\n {...getStyles('visibilityToggle')}\n disabled={disabled}\n radius={radius}\n aria-pressed={_visible}\n tabIndex={-1}\n aria-label=\"Toggle password visibility\"\n {...visibilityToggleButtonProps}\n variant={visibilityToggleButtonProps?.variant ?? 'subtle'}\n color=\"gray\"\n unstyled={unstyled}\n onTouchEnd={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onTouchEnd?.(event);\n toggleVisibility();\n }}\n onMouseDown={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onMouseDown?.(event);\n toggleVisibility();\n }}\n onKeyDown={(event) => {\n visibilityToggleButtonProps?.onKeyDown?.(event);\n if (event.key === ' ') {\n event.preventDefault();\n toggleVisibility();\n }\n }}\n >\n <VisibilityToggleIcon reveal={_visible} />\n </ActionIcon>\n );\n\n return (\n <Input.Wrapper\n required={required}\n id={uuid}\n label={label}\n error={error}\n description={description}\n size={size}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n unstyled={unstyled}\n withAsterisk={withAsterisk}\n inputWrapperOrder={inputWrapperOrder}\n inputContainer={inputContainer}\n variant={variant}\n labelProps={{ ...labelProps, htmlFor: uuid }}\n descriptionProps={{ ...descriptionProps, id: descriptionId }}\n errorProps={{ ...errorProps, id: errorId }}\n mod={mod}\n attributes={attributes}\n {...getStyles('root')}\n {...styleProps}\n {...wrapperProps}\n >\n <Input\n component=\"div\"\n error={error}\n leftSection={leftSection}\n size={size}\n classNames={{ ...resolvedClassNames, input: cx(classes.input, resolvedClassNames?.input) }}\n styles={resolvedStyles}\n radius={radius}\n disabled={disabled}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n rightSectionWidth={rightSectionWidth}\n rightSection={rightSection ?? visibilityToggleButton}\n variant={variant}\n unstyled={unstyled}\n leftSectionWidth={leftSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents || 'all'}\n rightSectionProps={rightSectionProps}\n leftSectionProps={leftSectionProps}\n leftSectionPointerEvents={leftSectionPointerEvents}\n withAria={false}\n withErrorStyles={withErrorStyles}\n attributes={attributes}\n >\n <input\n required={required}\n data-invalid={!!error || undefined}\n data-with-left-section={!!leftSection || undefined}\n {...getStyles('innerInput')}\n disabled={disabled}\n id={uuid}\n {...rest}\n aria-describedby={describedBy}\n autoComplete={rest.autoComplete || 'off'}\n type={_visible ? 'text' : 'password'}\n />\n </Input>\n </Input.Wrapper>\n );\n});\n\nPasswordInput.classes = { ...InputBase.classes, ...classes };\nPasswordInput.varsResolver = varsResolver;\nPasswordInput.displayName = '@mantine/core/PasswordInput';\n\nexport namespace PasswordInput {\n export type Props = PasswordInputProps;\n export type StylesNames = PasswordInputStylesNames;\n export type CssVariables = PasswordInputCssVariables;\n export type Factory = PasswordInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4DA,MAAM,eAAe;CACnB,sBAAsB;CACtB,MAAM;CACP;AAED,MAAM,eAAe,oBAA0C,GAAG,EAAE,YAAY,EAC9E,MAAM;CACJ,mBAAmB,QAAQ,MAAM,gBAAgB;CACjD,qBAAqB,QAAQ,MAAM,kBAAkB;CACtD,EACF,EAAE;AAEH,MAAa,gBAAgB,SAA+B,WAAW;CACrE,MAAM,QAAQ,SAAS;EAAC;EAAS;EAAgB;EAAgB,EAAE,cAAc,OAAO;CACxF,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,OACA,aACA,UACA,IACA,SACA,gBACA,aACA,OACA,MACA,YACA,kBACA,YACA,cACA,mBAC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AsB,QAAQ,UAAY,CAAA;EAC/B,CAAA;AAGf,QACE,oBAAC,MAAM,SAAP;EACY;EACV,IAAI;EACG;EACA;EACM;EACP;EACN,YAAY;EACZ,QAAQ;EACR,kBAAiB;EACjB,kBAAkB;EACR;EACI;EACK;EACH;EACP;EACT,YAAY;GAAE,GAAG;GAAY,SAAS;GAAM;EAC5C,kBAAkB;GAAE,GAAG;GAAkB,IAAI;GAAe;EAC5D,YAAY;GAAE,GAAG;GAAY,IAAI;GAAS;EACrC;EACO;EACZ,GAAI,UAAU,OAAO;EACrB,GAAI;EACJ,GAAI;YAEJ,oBAAC,OAAD;GACE,WAAU;GACH;GACM;GACP;GACN,YAAY;IAAE,GAAG;IAAoB,OAAO,GAAGA,6BAAQ,OAAO,oBAAoB,MAAM;IAAE;GAC1F,QAAQ;GACA;GACE;GACV,kBAAiB;GACjB,kBAAkB;GACC;GACnB,cAAc,gBAAgB;GACrB;GACC;GACQ;GAClB,2BAA2B,6BAA6B;GACrC;GACD;GACQ;GAC1B,UAAU;GACO;GACL;aAEZ,oBAAC,SAAD;IACY;IACV,gBAAc,CAAC,CAAC,SAAS,KAAA;IACzB,0BAAwB,CAAC,CAAC,eAAe,KAAA;IACzC,GAAI,UAAU,aAAa;IACjB;IACV,IAAI;IACJ,GAAI;IACJ,oBAAkB;IAClB,cAAc,KAAK,gBAAgB;IACnC,MAAM,WAAW,SAAS;IAC1B,CAAA;GACI,CAAA;EACM,CAAA;EAElB;AAEF,cAAc,UAAU;CAAE,GAAG,UAAU;CAAS,GAAGA;CAAS;AAC5D,cAAc,eAAe;AAC7B,cAAc,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Pill.module.mjs","names":[],"sources":["../../../src/components/Pill/Pill.module.css"],"sourcesContent":[".root {\n --pill-fz-xs: 10px;\n --pill-fz-sm: 12px;\n --pill-fz-md: 14px;\n --pill-fz-lg: 16px;\n --pill-fz-xl: 18px;\n\n --pill-height-xs: 18px;\n --pill-height-sm: 22px;\n --pill-height-md: 25px;\n --pill-height-lg: 28px;\n --pill-height-xl: 32px;\n\n --pill-fz: var(--pill-fz-sm);\n --pill-height: var(--pill-height-sm);\n\n font-size: var(--pill-fz);\n flex: 0;\n height: var(--pill-height);\n padding-inline: 0.8em;\n display: inline-flex;\n align-items: center;\n border-radius: var(--pill-radius, 1000rem);\n line-height: 1;\n white-space: nowrap;\n user-select: none;\n -webkit-user-select: none;\n max-width: 100%;\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-7);\n color: var(--mantine-color-dark-0);\n }\n\n @mixin where-light {\n color: var(--mantine-color-black);\n }\n\n &:where([data-with-remove]:not(:has(button:disabled))) {\n padding-inline-end: 0;\n }\n\n &:where([data-disabled], :has(button:disabled)) {\n cursor: not-allowed;\n }\n}\n\n.root--default {\n @mixin where-light {\n background-color: var(--mantine-color-gray-1);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.root--contrast {\n @mixin where-light {\n background-color: var(--mantine-color-white);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.label {\n cursor: inherit;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n height: 100%;\n text-box-trim: trim-both;\n text-box-edge: cap alphabetic;\n}\n\n.remove {\n color: inherit;\n font-size: inherit;\n height: 100%;\n min-height: unset;\n min-width: 2em;\n width: unset;\n border-radius: 0;\n padding-inline-start: 0.1em;\n padding-inline-end: 0.3em;\n flex: 0;\n border-end-end-radius: var(--pill-radius, 50%);\n border-start-end-radius: var(--pill-radius, 50%);\n\n .root[data-disabled] > &,\n &:disabled {\n display: none;\n background-color: transparent;\n width: 0.8em;\n min-width: 0.8em;\n padding: 0;\n cursor: not-allowed;\n\n & > svg {\n display: none;\n }\n }\n\n & > svg {\n pointer-events: none;\n }\n}\n\n.group {\n --pg-gap-xs: 6px;\n --pg-gap-sm: 8px;\n --pg-gap-md: 10px;\n --pg-gap-lg: 12px;\n --pg-gap-xl: 12px;\n --pg-gap: var(--pg-gap-sm);\n\n display: flex;\n align-items: center;\n gap: var(--pg-gap);\n flex-wrap: wrap;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"Pill.module.mjs","names":[],"sources":["../../../src/components/Pill/Pill.module.css"],"sourcesContent":[".root {\n --pill-fz-xs: 10px;\n --pill-fz-sm: 12px;\n --pill-fz-md: 14px;\n --pill-fz-lg: 16px;\n --pill-fz-xl: 18px;\n\n --pill-height-xs: 18px;\n --pill-height-sm: 22px;\n --pill-height-md: 25px;\n --pill-height-lg: 28px;\n --pill-height-xl: 32px;\n\n --pill-fz: var(--pill-fz-sm);\n --pill-height: var(--pill-height-sm);\n\n font-size: var(--pill-fz);\n flex: 0;\n height: var(--pill-height);\n padding-inline: 0.8em;\n display: inline-flex;\n align-items: center;\n border-radius: var(--pill-radius, 1000rem);\n line-height: 1;\n white-space: nowrap;\n user-select: none;\n -webkit-user-select: none;\n max-width: 100%;\n position: relative;\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-7);\n color: var(--mantine-color-dark-0);\n }\n\n @mixin where-light {\n color: var(--mantine-color-black);\n }\n\n &:where([data-with-remove]:not(:has(button:disabled))) {\n padding-inline-end: 0;\n }\n\n &:where([data-disabled], :has(button:disabled)) {\n cursor: not-allowed;\n }\n\n &:where([draggable='true']) {\n cursor: grab;\n }\n\n &:where([draggable='true']):focus-visible {\n outline: 2px solid var(--mantine-primary-color-filled);\n outline-offset: 2px;\n }\n\n &:where([data-dragging]) {\n opacity: 0.4;\n cursor: grabbing;\n }\n\n &:where([data-drag-over='before'])::before,\n &:where([data-drag-over='after'])::after {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n width: rem(2px);\n background-color: var(--mantine-primary-color-filled);\n pointer-events: none;\n z-index: 1;\n }\n\n &:where([data-drag-over='before'])::before {\n inset-inline-start: rem(-4px);\n }\n\n &:where([data-drag-over='after'])::after {\n inset-inline-end: rem(-4px);\n }\n}\n\n.root--default {\n @mixin where-light {\n background-color: var(--mantine-color-gray-1);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.root--contrast {\n @mixin where-light {\n background-color: var(--mantine-color-white);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.label {\n cursor: inherit;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n height: 100%;\n text-box-trim: trim-both;\n text-box-edge: cap alphabetic;\n}\n\n.remove {\n color: inherit;\n font-size: inherit;\n height: 100%;\n min-height: unset;\n min-width: 2em;\n width: unset;\n border-radius: 0;\n padding-inline-start: 0.1em;\n padding-inline-end: 0.3em;\n flex: 0;\n border-end-end-radius: var(--pill-radius, 50%);\n border-start-end-radius: var(--pill-radius, 50%);\n\n .root[data-disabled] > &,\n &:disabled {\n display: none;\n background-color: transparent;\n width: 0.8em;\n min-width: 0.8em;\n padding: 0;\n cursor: not-allowed;\n\n & > svg {\n display: none;\n }\n }\n\n & > svg {\n pointer-events: none;\n }\n}\n\n.group {\n --pg-gap-xs: 6px;\n --pg-gap-sm: 8px;\n --pg-gap-md: 10px;\n --pg-gap-lg: 12px;\n --pg-gap-xl: 12px;\n --pg-gap: var(--pg-gap-sm);\n\n display: flex;\n align-items: center;\n gap: var(--pg-gap);\n flex-wrap: wrap;\n}\n"],"mappings":""}
@@ -9,7 +9,11 @@ import { jsx } from "react/jsx-runtime";
9
9
  //#region packages/@mantine/core/src/components/PillsInput/PillsInput.tsx
10
10
  const defaultProps = { size: "sm" };
11
11
  const PillsInput = factory((_props) => {
12
- const { children, onMouseDown, onClick, size, disabled, __staticSelector, error, variant, ...others } = useProps("PillsInput", defaultProps, _props);
12
+ const { children, onMouseDown, onClick, size, disabled, __staticSelector, error, variant, ...others } = useProps([
13
+ "Input",
14
+ "InputWrapper",
15
+ "PillsInput"
16
+ ], defaultProps, _props);
13
17
  const fieldRef = useRef(null);
14
18
  return /* @__PURE__ */ jsx(PillsInputContext, {
15
19
  value: {
@@ -1 +1 @@
1
- {"version":3,"file":"PillsInput.mjs","names":[],"sources":["../../../src/components/PillsInput/PillsInput.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PillsInputContext, type PillsInputContextValue } from './PillsInput.context';\nimport {\n PillsInputField,\n type PillsInputFieldProps,\n type PillsInputFieldFactory,\n type PillsInputFieldStylesNames,\n} from './PillsInputField/PillsInputField';\nexport interface PillsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<PillsInputFactory>,\n ElementProps<'div', 'size'> {\n __stylesApiProps?: Record<string, any>;\n __staticSelector?: string;\n}\n\nexport type PillsInputFactory = Factory<{\n props: PillsInputProps;\n ref: HTMLDivElement;\n stylesNames: __InputStylesNames;\n staticComponents: {\n Field: typeof PillsInputField;\n };\n}>;\n\nconst defaultProps = {\n size: 'sm',\n} satisfies Partial<PillsInputProps>;\n\nexport const PillsInput = factory<PillsInputFactory>((_props) => {\n const props = useProps('PillsInput', defaultProps, _props);\n const {\n children,\n onMouseDown,\n onClick,\n size,\n disabled,\n __staticSelector,\n error,\n variant,\n ...others\n } = props;\n\n const fieldRef = useRef<HTMLInputElement>(null);\n\n return (\n <PillsInputContext value={{ fieldRef, size, disabled, hasError: !!error, variant }}>\n <InputBase\n size={size}\n error={error}\n variant={variant}\n component=\"div\"\n data-no-overflow\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n fieldRef.current?.focus();\n }}\n onClick={(event) => {\n event.preventDefault();\n const fieldset = event.currentTarget.closest('fieldset');\n if (!fieldset?.disabled) {\n fieldRef.current?.focus();\n onClick?.(event);\n }\n }}\n {...others}\n multiline\n disabled={disabled}\n __staticSelector={__staticSelector || 'PillsInput'}\n withAria={false}\n >\n {children}\n </InputBase>\n </PillsInputContext>\n );\n});\n\nPillsInput.displayName = '@mantine/core/PillsInput';\nPillsInput.classes = InputBase.classes;\nPillsInput.Field = PillsInputField;\n\nexport namespace PillsInput {\n export type Props = PillsInputProps;\n export type Factory = PillsInputFactory;\n export type ContextValue = PillsInputContextValue;\n\n export namespace Field {\n export type Props = PillsInputFieldProps;\n export type Factory = PillsInputFieldFactory;\n export type StylesNames = PillsInputFieldStylesNames;\n }\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,eAAe,EACnB,MAAM,MACP;AAED,MAAa,aAAa,SAA4B,WAAW;CAE/D,MAAM,EACJ,UACA,aACA,SACA,MACA,UACA,kBACA,OACA,SACA,GAAG,WAVS,SAAS,cAAc,cAAc,OAAO;CAa1D,MAAM,WAAW,OAAyB,KAAK;AAE/C,QACE,oBAAC,mBAAD;EAAmB,OAAO;GAAE;GAAU;GAAM;GAAU,UAAU,CAAC,CAAC;GAAO;GAAS;YAChF,oBAAC,WAAD;GACQ;GACC;GACE;GACT,WAAU;GACV,oBAAA;GACA,cAAc,UAAU;AACtB,UAAM,gBAAgB;AACtB,kBAAc,MAAM;AACpB,aAAS,SAAS,OAAO;;GAE3B,UAAU,UAAU;AAClB,UAAM,gBAAgB;AAEtB,QAAI,CADa,MAAM,cAAc,QAAQ,WAAW,EACzC,UAAU;AACvB,cAAS,SAAS,OAAO;AACzB,eAAU,MAAM;;;GAGpB,GAAI;GACJ,WAAA;GACU;GACV,kBAAkB,oBAAoB;GACtC,UAAU;GAET;GACS,CAAA;EACM,CAAA;EAEtB;AAEF,WAAW,cAAc;AACzB,WAAW,UAAU,UAAU;AAC/B,WAAW,QAAQ"}
1
+ {"version":3,"file":"PillsInput.mjs","names":[],"sources":["../../../src/components/PillsInput/PillsInput.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PillsInputContext, type PillsInputContextValue } from './PillsInput.context';\nimport {\n PillsInputField,\n type PillsInputFieldProps,\n type PillsInputFieldFactory,\n type PillsInputFieldStylesNames,\n} from './PillsInputField/PillsInputField';\nexport interface PillsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<PillsInputFactory>,\n ElementProps<'div', 'size'> {\n __stylesApiProps?: Record<string, any>;\n __staticSelector?: string;\n}\n\nexport type PillsInputFactory = Factory<{\n props: PillsInputProps;\n ref: HTMLDivElement;\n stylesNames: __InputStylesNames;\n staticComponents: {\n Field: typeof PillsInputField;\n };\n}>;\n\nconst defaultProps = {\n size: 'sm',\n} satisfies Partial<PillsInputProps>;\n\nexport const PillsInput = factory<PillsInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'PillsInput'], defaultProps, _props);\n const {\n children,\n onMouseDown,\n onClick,\n size,\n disabled,\n __staticSelector,\n error,\n variant,\n ...others\n } = props;\n\n const fieldRef = useRef<HTMLInputElement>(null);\n\n return (\n <PillsInputContext value={{ fieldRef, size, disabled, hasError: !!error, variant }}>\n <InputBase\n size={size}\n error={error}\n variant={variant}\n component=\"div\"\n data-no-overflow\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n fieldRef.current?.focus();\n }}\n onClick={(event) => {\n event.preventDefault();\n const fieldset = event.currentTarget.closest('fieldset');\n if (!fieldset?.disabled) {\n fieldRef.current?.focus();\n onClick?.(event);\n }\n }}\n {...others}\n multiline\n disabled={disabled}\n __staticSelector={__staticSelector || 'PillsInput'}\n withAria={false}\n >\n {children}\n </InputBase>\n </PillsInputContext>\n );\n});\n\nPillsInput.displayName = '@mantine/core/PillsInput';\nPillsInput.classes = InputBase.classes;\nPillsInput.Field = PillsInputField;\n\nexport namespace PillsInput {\n export type Props = PillsInputProps;\n export type Factory = PillsInputFactory;\n export type ContextValue = PillsInputContextValue;\n\n export namespace Field {\n export type Props = PillsInputFieldProps;\n export type Factory = PillsInputFieldFactory;\n export type StylesNames = PillsInputFieldStylesNames;\n }\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,eAAe,EACnB,MAAM,MACP;AAED,MAAa,aAAa,SAA4B,WAAW;CAE/D,MAAM,EACJ,UACA,aACA,SACA,MACA,UACA,kBACA,OACA,SACA,GAAG,WAVS,SAAS;EAAC;EAAS;EAAgB;EAAa,EAAE,cAAc,OAAO;CAarF,MAAM,WAAW,OAAyB,KAAK;AAE/C,QACE,oBAAC,mBAAD;EAAmB,OAAO;GAAE;GAAU;GAAM;GAAU,UAAU,CAAC,CAAC;GAAO;GAAS;YAChF,oBAAC,WAAD;GACQ;GACC;GACE;GACT,WAAU;GACV,oBAAA;GACA,cAAc,UAAU;AACtB,UAAM,gBAAgB;AACtB,kBAAc,MAAM;AACpB,aAAS,SAAS,OAAO;;GAE3B,UAAU,UAAU;AAClB,UAAM,gBAAgB;AAEtB,QAAI,CADa,MAAM,cAAc,QAAQ,WAAW,EACzC,UAAU;AACvB,cAAS,SAAS,OAAO;AACzB,eAAU,MAAM;;;GAGpB,GAAI;GACJ,WAAA;GACU;GACV,kBAAkB,oBAAoB;GACtC,UAAU;GAET;GACS,CAAA;EACM,CAAA;EAEtB;AAEF,WAAW,cAAc;AACzB,WAAW,UAAU,UAAU;AAC/B,WAAW,QAAQ"}
@@ -30,7 +30,7 @@ const defaultProps = {
30
30
  };
31
31
  const varsResolver = createVarsResolver((_, { size }) => ({ root: { "--pin-input-size": getSize(size ?? "sm", "pin-input-size") } }));
32
32
  const PinInput = factory((props) => {
33
- const { name, form, className, value, defaultValue, variant, gap, style, size, classNames, styles, unstyled, length, onChange, onComplete, manageFocus, autoFocus, error, radius, disabled, oneTimeCode, placeholder, type, mask, readOnly, inputType, inputMode, ariaLabel, vars, id, hiddenInputProps, rootRef, getInputProps, attributes, ref, ...others } = useProps("PinInput", defaultProps, props);
33
+ const { name, form, className, value, defaultValue, variant, gap, style, size, classNames, styles, unstyled, length, onChange, onComplete, manageFocus, autoFocus, error, radius, disabled, oneTimeCode, placeholder, type, mask, readOnly, inputType, inputMode, ariaLabel, vars, id, hiddenInputProps, rootRef, getInputProps, attributes, ref, ...others } = useProps(["Input", "PinInput"], defaultProps, props);
34
34
  const uuid = useId$1(id);
35
35
  const getStyles = useStyles({
36
36
  name: "PinInput",