@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
@@ -14,7 +14,11 @@ let _mantine_hooks = require("@mantine/hooks");
14
14
  let react_jsx_runtime = require("react/jsx-runtime");
15
15
  //#region packages/@mantine/core/src/components/Autocomplete/Autocomplete.tsx
16
16
  const Autocomplete = require_factory.factory((_props) => {
17
- const props = require_use_props.useProps("Autocomplete", { size: "sm" }, _props);
17
+ const props = require_use_props.useProps([
18
+ "Input",
19
+ "InputWrapper",
20
+ "Autocomplete"
21
+ ], { size: "sm" }, _props);
18
22
  const { classNames, styles, unstyled, vars, dropdownOpened, defaultDropdownOpened, onDropdownClose, onDropdownOpen, onFocus, onBlur, onClick, onChange, data, value, defaultValue, selectFirstOptionOnChange, selectFirstOptionOnDropdownOpen, onOptionSubmit, comboboxProps, readOnly, disabled, filter, limit, withScrollArea, maxDropdownHeight, size, id, renderOption, autoComplete, scrollAreaProps, onClear, clearButtonProps, error, clearable, clearSectionMode, rightSection, autoSelectOnBlur, openOnFocus = true, attributes, ...others } = props;
19
23
  const _id = (0, _mantine_hooks.useId)(id);
20
24
  const parsedData = require_get_parsed_combobox_data.getParsedComboboxData(data);
@@ -1 +1 @@
1
- {"version":3,"file":"Autocomplete.cjs","names":["factory","useProps","getParsedComboboxData","getOptionsLockup","useCombobox","useResolvedStylesApi","Combobox","InputBase","OptionsDropdown"],"sources":["../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n factory,\n Factory,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport {\n Combobox,\n ComboboxGenericData,\n ComboboxGenericItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { ScrollAreaProps } from '../ScrollArea';\n\nexport type RenderAutocompleteOption = (\n input: ComboboxLikeRenderOptionInput<ComboboxGenericItem>\n) => React.ReactNode;\n\nexport type AutocompleteStylesNames = __InputStylesNames | ComboboxLikeStylesNames;\n\nexport interface AutocompleteProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n Omit<ComboboxLikeProps, 'data'>,\n StylesApiProps<AutocompleteFactory>,\n ElementProps<'input', 'onChange' | 'size'> {\n /** Data used to display options. Values must be unique. */\n data?: ComboboxGenericData;\n\n /** Controlled component value */\n value?: string;\n\n /** Default value for uncontrolled component */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Function to render custom option content */\n renderOption?: RenderAutocompleteOption;\n\n /** Props passed to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** If set, the clear button is displayed when the component has a value @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** If set, the highlighted option is selected when the input loses focus @default false */\n autoSelectOnBlur?: boolean;\n\n /** If set, the dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n}\n\nexport type AutocompleteFactory = Factory<{\n props: AutocompleteProps;\n ref: HTMLInputElement;\n stylesNames: AutocompleteStylesNames;\n variant: InputVariant;\n}>;\n\nexport const Autocomplete = factory<AutocompleteFactory>((_props) => {\n const props = useProps(\n 'Autocomplete',\n { size: 'sm' } satisfies Partial<AutocompleteProps>,\n _props\n );\n const {\n classNames,\n styles,\n unstyled,\n vars,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownClose,\n onDropdownOpen,\n onFocus,\n onBlur,\n onClick,\n onChange,\n data,\n value,\n defaultValue,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n readOnly,\n disabled,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n size,\n id,\n renderOption,\n autoComplete,\n scrollAreaProps,\n onClear,\n clearButtonProps,\n error,\n clearable,\n clearSectionMode,\n rightSection,\n autoSelectOnBlur,\n openOnFocus = true,\n attributes,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\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 // Required for autoSelectOnBlur to work correctly\n setTimeout(combobox.resetSelectedOption, 0);\n },\n });\n\n const handleValueChange = (value: string) => {\n setValue(value);\n combobox.resetSelectedOption();\n };\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<AutocompleteFactory>({\n props,\n styles,\n classNames,\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n handleValueChange('');\n onClear?.();\n }}\n />\n );\n\n return (\n <Combobox\n store={combobox}\n __staticSelector=\"Autocomplete\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n keepMounted={autoSelectOnBlur}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val);\n handleValueChange(optionsLockup[val].label);\n combobox.closeDropdown();\n }}\n {...comboboxProps}\n >\n <Combobox.Target autoComplete={autoComplete} withExpandedAttribute>\n <InputBase\n {...others}\n size={size}\n __staticSelector=\"Autocomplete\"\n __clearSection={clearButton}\n __clearable={clearable && !!_value && !disabled && !readOnly}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n disabled={disabled}\n readOnly={readOnly}\n value={_value}\n error={error}\n onChange={(event) => {\n handleValueChange(event.currentTarget.value);\n combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n onFocus={(event) => {\n openOnFocus && combobox.openDropdown();\n onFocus?.(event);\n }}\n onBlur={(event) => {\n if (autoSelectOnBlur) {\n combobox.clickSelectedOption();\n }\n\n combobox.closeDropdown();\n onBlur?.(event);\n }}\n onClick={(event) => {\n combobox.openDropdown();\n onClick?.(event);\n }}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n attributes={attributes}\n id={_id}\n />\n </Combobox.Target>\n <OptionsDropdown\n data={parsedData}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_value}\n limit={limit}\n hiddenWhenEmpty\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n unstyled={unstyled}\n labelId={others.label ? `${_id}-label` : undefined}\n aria-label={others.label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n );\n});\n\nAutocomplete.classes = { ...InputBase.classes, ...Combobox.classes };\nAutocomplete.displayName = '@mantine/core/Autocomplete';\n\nexport namespace Autocomplete {\n export type Props = AutocompleteProps;\n export type StylesNames = AutocompleteStylesNames;\n export type RenderOption = RenderAutocompleteOption;\n export type Factory = AutocompleteFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4FA,MAAa,eAAeA,gBAAAA,SAA8B,WAAW;CACnE,MAAM,QAAQC,kBAAAA,SACZ,gBACA,EAAE,MAAM,MAAM,EACd,OACD;CACD,MAAM,EACJ,YACA,QACA,UACA,MACA,gBACA,uBACA,iBACA,gBACA,SACA,QACA,SACA,UACA,MACA,OACA,cACA,2BACA,iCACA,gBACA,eACA,UACA,UACA,QACA,OACA,gBACA,mBACA,MACA,IACA,cACA,cACA,iBACA,SACA,kBACA,OACA,WACA,kBACA,cACA,kBACA,cAAc,MACd,YACA,GAAG,WACD;CAEJ,MAAM,OAAA,GAAA,eAAA,OAAY,GAAG;CACrB,MAAM,aAAaC,iCAAAA,sBAAsB,KAAK;CAC9C,MAAM,gBAAgBC,2BAAAA,iBAAiB,WAAW;CAElD,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAA4B;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,WAAWC,qBAAAA,YAAY;EAC3B,QAAQ;EACR,eAAe;EACf,sBAAsB;AACpB,qBAAkB;AAClB,OAAI,gCACF,UAAS,mBAAmB;;EAGhC,uBAAuB;AACrB,sBAAmB;AAEnB,cAAW,SAAS,qBAAqB,EAAE;;EAE9C,CAAC;CAEF,MAAM,qBAAqB,UAAkB;AAC3C,WAAS,MAAM;AACf,WAAS,qBAAqB;;CAGhC,MAAM,EAAE,oBAAoB,mBAAmBC,gCAAAA,qBAA0C;EACvF;EACA;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;GACD;GACP,iBAAA;GACgB;GACG;GACT;GACV,SAAS,OAAO,QAAQ,GAAG,IAAI,UAAU,KAAA;GACzC,cAAY,OAAO,QAAQ,KAAA,IAAY,OAAO;GAChC;GACG;GACjB,CAAA,CACO;;EAEb;AAEF,aAAa,UAAU;CAAE,GAAGD,kBAAAA,UAAU;CAAS,GAAGD,iBAAAA,SAAS;CAAS;AACpE,aAAa,cAAc"}
1
+ {"version":3,"file":"Autocomplete.cjs","names":["factory","useProps","getParsedComboboxData","getOptionsLockup","useCombobox","useResolvedStylesApi","Combobox","InputBase","OptionsDropdown"],"sources":["../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n factory,\n Factory,\n Primitive,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport {\n Combobox,\n ComboboxGenericData,\n ComboboxGenericItem,\n ComboboxLikeProps,\n ComboboxLikeRenderOptionInput,\n ComboboxLikeStylesNames,\n getOptionsLockup,\n getParsedComboboxData,\n OptionsDropdown,\n OptionsFilter,\n useCombobox,\n} from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { ScrollAreaProps } from '../ScrollArea';\n\nexport type RenderAutocompleteOption = (\n input: ComboboxLikeRenderOptionInput<ComboboxGenericItem>\n) => React.ReactNode;\n\nexport type AutocompleteStylesNames = __InputStylesNames | ComboboxLikeStylesNames;\n\nexport interface AutocompleteProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n Omit<ComboboxLikeProps, 'data'>,\n StylesApiProps<AutocompleteFactory>,\n ElementProps<'input', 'onChange' | 'size'> {\n /** Data used to display options. Values must be unique. */\n data?: ComboboxGenericData;\n\n /** Controlled component value */\n value?: string;\n\n /** Default value for uncontrolled component */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Function to render custom option content */\n renderOption?: RenderAutocompleteOption;\n\n /** Props passed to the underlying `ScrollArea` component in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** If set, the clear button is displayed when the component has a value @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** If set, the highlighted option is selected when the input loses focus @default false */\n autoSelectOnBlur?: boolean;\n\n /** If set, the dropdown opens when the input receives focus @default true */\n openOnFocus?: boolean;\n}\n\nexport type AutocompleteFactory = Factory<{\n props: AutocompleteProps;\n ref: HTMLInputElement;\n stylesNames: AutocompleteStylesNames;\n variant: InputVariant;\n}>;\n\nexport const Autocomplete = factory<AutocompleteFactory>((_props) => {\n const props = useProps(\n ['Input', 'InputWrapper', 'Autocomplete'],\n { size: 'sm' } satisfies Partial<AutocompleteProps>,\n _props\n );\n const {\n classNames,\n styles,\n unstyled,\n vars,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownClose,\n onDropdownOpen,\n onFocus,\n onBlur,\n onClick,\n onChange,\n data,\n value,\n defaultValue,\n selectFirstOptionOnChange,\n selectFirstOptionOnDropdownOpen,\n onOptionSubmit,\n comboboxProps,\n readOnly,\n disabled,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n size,\n id,\n renderOption,\n autoComplete,\n scrollAreaProps,\n onClear,\n clearButtonProps,\n error,\n clearable,\n clearSectionMode,\n rightSection,\n autoSelectOnBlur,\n openOnFocus = true,\n attributes,\n ...others\n } = props;\n\n const _id = useId(id);\n const parsedData = getParsedComboboxData(data);\n const optionsLockup = getOptionsLockup(parsedData);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\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 // Required for autoSelectOnBlur to work correctly\n setTimeout(combobox.resetSelectedOption, 0);\n },\n });\n\n const handleValueChange = (value: string) => {\n setValue(value);\n combobox.resetSelectedOption();\n };\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<AutocompleteFactory>({\n props,\n styles,\n classNames,\n });\n\n useEffect(() => {\n if (selectFirstOptionOnChange) {\n combobox.selectFirstOption();\n }\n }, [selectFirstOptionOnChange, _value]);\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n handleValueChange('');\n onClear?.();\n }}\n />\n );\n\n return (\n <Combobox\n store={combobox}\n __staticSelector=\"Autocomplete\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n keepMounted={autoSelectOnBlur}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val);\n handleValueChange(optionsLockup[val].label);\n combobox.closeDropdown();\n }}\n {...comboboxProps}\n >\n <Combobox.Target autoComplete={autoComplete} withExpandedAttribute>\n <InputBase\n {...others}\n size={size}\n __staticSelector=\"Autocomplete\"\n __clearSection={clearButton}\n __clearable={clearable && !!_value && !disabled && !readOnly}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n disabled={disabled}\n readOnly={readOnly}\n value={_value}\n error={error}\n onChange={(event) => {\n handleValueChange(event.currentTarget.value);\n combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n onFocus={(event) => {\n openOnFocus && combobox.openDropdown();\n onFocus?.(event);\n }}\n onBlur={(event) => {\n if (autoSelectOnBlur) {\n combobox.clickSelectedOption();\n }\n\n combobox.closeDropdown();\n onBlur?.(event);\n }}\n onClick={(event) => {\n combobox.openDropdown();\n onClick?.(event);\n }}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n attributes={attributes}\n id={_id}\n />\n </Combobox.Target>\n <OptionsDropdown\n data={parsedData}\n hidden={readOnly || disabled}\n filter={filter as OptionsFilter<Primitive> | undefined}\n search={_value}\n limit={limit}\n hiddenWhenEmpty\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n unstyled={unstyled}\n labelId={others.label ? `${_id}-label` : undefined}\n aria-label={others.label ? undefined : others['aria-label']}\n renderOption={renderOption}\n scrollAreaProps={scrollAreaProps}\n />\n </Combobox>\n );\n});\n\nAutocomplete.classes = { ...InputBase.classes, ...Combobox.classes };\nAutocomplete.displayName = '@mantine/core/Autocomplete';\n\nexport namespace Autocomplete {\n export type Props = AutocompleteProps;\n export type StylesNames = AutocompleteStylesNames;\n export type RenderOption = RenderAutocompleteOption;\n export type Factory = AutocompleteFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4FA,MAAa,eAAeA,gBAAAA,SAA8B,WAAW;CACnE,MAAM,QAAQC,kBAAAA,SACZ;EAAC;EAAS;EAAgB;EAAe,EACzC,EAAE,MAAM,MAAM,EACd,OACD;CACD,MAAM,EACJ,YACA,QACA,UACA,MACA,gBACA,uBACA,iBACA,gBACA,SACA,QACA,SACA,UACA,MACA,OACA,cACA,2BACA,iCACA,gBACA,eACA,UACA,UACA,QACA,OACA,gBACA,mBACA,MACA,IACA,cACA,cACA,iBACA,SACA,kBACA,OACA,WACA,kBACA,cACA,kBACA,cAAc,MACd,YACA,GAAG,WACD;CAEJ,MAAM,OAAA,GAAA,eAAA,OAAY,GAAG;CACrB,MAAM,aAAaC,iCAAAA,sBAAsB,KAAK;CAC9C,MAAM,gBAAgBC,2BAAAA,iBAAiB,WAAW;CAElD,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAA4B;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,WAAWC,qBAAAA,YAAY;EAC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U;AACjB,SAAI,iBACF,UAAS,qBAAqB;AAGhC,cAAS,eAAe;AACxB,cAAS,MAAM;;IAEjB,UAAU,UAAU;AAClB,cAAS,cAAc;AACvB,eAAU,MAAM;;IAElB,YAAY;IACZ,QAAQ;IACE;IACE;IACZ,IAAI;IACJ,CAAA;GACc,CAAA,EAClB,iBAAA,GAAA,kBAAA,KAACC,wBAAAA,iBAAD;GACE,MAAM;GACN,QAAQ,YAAY;GACZ;GACR,QAAQ;GACD;GACP,iBAAA;GACgB;GACG;GACT;GACV,SAAS,OAAO,QAAQ,GAAG,IAAI,UAAU,KAAA;GACzC,cAAY,OAAO,QAAQ,KAAA,IAAY,OAAO;GAChC;GACG;GACjB,CAAA,CACO;;EAEb;AAEF,aAAa,UAAU;CAAE,GAAGD,kBAAAA,UAAU;CAAS,GAAGD,iBAAAA,SAAS;CAAS;AACpE,aAAa,cAAc"}
@@ -111,7 +111,10 @@ const Checkbox = require_factory.factory((_props) => {
111
111
  component: "input",
112
112
  id: uuid,
113
113
  ref: (0, _mantine_hooks.useMergedRef)(inputRef, ref),
114
- mod: { error: !!error },
114
+ mod: {
115
+ error: !!error,
116
+ "with-error-styles": withErrorStyles
117
+ },
115
118
  ...getStyles("input", {
116
119
  focusable: true,
117
120
  variant
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.cjs","names":["CheckboxIcon","createVarsResolver","parseThemeColor","getSize","getRadius","getThemeColor","getAutoContrastValue","getContrastColor","factory","useProps","CheckboxGroupContext","useStyles","extractStyleProps","InlineInput","Box","classes","InlineInputClasses","CheckboxGroup","CheckboxIndicator","CheckboxCard"],"sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { use, useEffect, useRef } from 'react';\nimport { useId, useMergedRef } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getAutoContrastValue,\n getContrastColor,\n getRadius,\n getSize,\n getThemeColor,\n MantineColor,\n MantineRadius,\n MantineSize,\n parseThemeColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { InlineInput, InlineInputClasses, InlineInputStylesNames } from '../../utils/InlineInput';\nimport {\n CheckboxCard,\n type CheckboxCardProps,\n type CheckboxCardStylesNames,\n type CheckboxCardCssVariables,\n type CheckboxCardFactory,\n} from './CheckboxCard/CheckboxCard';\nimport {\n CheckboxGroup,\n CheckboxGroupContext,\n type CheckboxGroupProps,\n type CheckboxGroupStylesNames,\n type CheckboxGroupFactory,\n} from './CheckboxGroup/CheckboxGroup';\nimport {\n CheckboxIndicator,\n type CheckboxIndicatorProps,\n type CheckboxIndicatorStylesNames,\n type CheckboxIndicatorCssVariables,\n type CheckboxIndicatorFactory,\n type CheckboxIndicatorVariant,\n} from './CheckboxIndicator/CheckboxIndicator';\nimport { CheckboxIcon } from './CheckIcon';\nimport classes from './Checkbox.module.css';\nexport type CheckboxVariant = 'filled' | 'outline';\nexport type CheckboxStylesNames = 'icon' | 'inner' | 'input' | InlineInputStylesNames;\nexport type CheckboxCssVariables = {\n root: '--checkbox-size' | '--checkbox-radius' | '--checkbox-color' | '--checkbox-icon-color';\n};\n\nexport type CheckboxIconComponent = React.FC<{\n indeterminate: boolean | undefined;\n className: string;\n}>;\n\nexport interface CheckboxProps\n extends BoxProps, StylesApiProps<CheckboxFactory>, ElementProps<'input', 'size' | 'children'> {\n /** Unique input id */\n id?: string;\n\n /** `label` associated with the checkbox */\n label?: React.ReactNode;\n\n /** Key of `theme.colors` or any valid CSS color to set input background color in checked state @default theme.primaryColor */\n color?: MantineColor;\n\n /** Controls size of the component @default 'sm' */\n size?: MantineSize | (string & {});\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Props passed down to the root element */\n wrapperProps?: React.ComponentProps<'div'> & DataAttributes;\n\n /** Position of the label relative to the input @default 'right' */\n labelPosition?: 'left' | 'right';\n\n /** Description below the label */\n description?: React.ReactNode;\n\n /** Error message below the label */\n error?: React.ReactNode;\n\n /** Indeterminate state of the checkbox. If set, `checked` prop is dismissed. */\n indeterminate?: boolean;\n\n /** Icon for checked or indeterminate state */\n icon?: CheckboxIconComponent;\n\n /** Root element ref */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Key of `theme.colors` or any valid CSS color to set icon color. By default, depends on `theme.autoContrast`. */\n iconColor?: MantineColor;\n\n /** If set, adjusts icon color based on background color for `filled` variant */\n autoContrast?: boolean;\n\n /** If set, applies error styles to the checkbox when `error` prop is set @default true */\n withErrorStyles?: boolean;\n}\n\nexport type CheckboxFactory = Factory<{\n props: CheckboxProps;\n ref: HTMLInputElement;\n stylesNames: CheckboxStylesNames;\n vars: CheckboxCssVariables;\n variant: CheckboxVariant;\n staticComponents: {\n Group: typeof CheckboxGroup;\n Indicator: typeof CheckboxIndicator;\n Card: typeof CheckboxCard;\n };\n}>;\n\nconst defaultProps = {\n labelPosition: 'right',\n icon: CheckboxIcon,\n withErrorStyles: true,\n variant: 'filled',\n radius: 'sm',\n} satisfies Partial<CheckboxProps>;\n\nconst varsResolver = createVarsResolver<CheckboxFactory>(\n (theme, { radius, color, size, iconColor, variant, autoContrast }) => {\n const parsedColor = parseThemeColor({ color: color || theme.primaryColor, theme });\n const outlineColor =\n parsedColor.isThemeColor && parsedColor.shade === undefined\n ? `var(--mantine-color-${parsedColor.color}-outline)`\n : parsedColor.color;\n\n return {\n root: {\n '--checkbox-size': getSize(size, 'checkbox-size'),\n '--checkbox-radius': radius === undefined ? undefined : getRadius(radius),\n '--checkbox-color': variant === 'outline' ? outlineColor : getThemeColor(color, theme),\n '--checkbox-icon-color': iconColor\n ? getThemeColor(iconColor, theme)\n : getAutoContrastValue(autoContrast, theme)\n ? getContrastColor({ color, theme, autoContrast })\n : undefined,\n },\n };\n }\n);\n\nexport const Checkbox = factory<CheckboxFactory>((_props) => {\n const props = useProps('Checkbox', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n color,\n label,\n id,\n size,\n radius,\n wrapperProps,\n checked,\n labelPosition,\n description,\n error,\n disabled,\n variant,\n indeterminate,\n icon: Icon,\n rootRef,\n iconColor,\n onChange,\n autoContrast,\n mod,\n attributes,\n readOnly,\n onClick,\n withErrorStyles,\n ref,\n ...others\n } = props;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const ctx = use(CheckboxGroupContext);\n const _size = size || ctx?.size;\n\n const getStyles = useStyles<CheckboxFactory>({\n name: 'Checkbox',\n props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const uuid = useId(id);\n\n const withContextProps = {\n checked: ctx?.value.includes(rest.value as string) ?? checked,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n ctx?.onChange(event);\n onChange?.(event);\n },\n };\n\n const isDisabledByGroup = ctx?.isDisabled?.(rest.value as string) ?? false;\n const finalDisabled = disabled || isDisabledByGroup;\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = indeterminate || false;\n\n if (indeterminate) {\n inputRef.current.setAttribute('data-indeterminate', 'true');\n } else {\n inputRef.current.removeAttribute('data-indeterminate');\n }\n }\n }, [indeterminate]);\n\n return (\n <InlineInput\n {...getStyles('root')}\n __staticSelector=\"Checkbox\"\n __stylesApiProps={props}\n id={uuid}\n size={_size}\n labelPosition={labelPosition}\n label={label}\n description={description}\n error={error}\n disabled={finalDisabled}\n classNames={classNames}\n styles={styles}\n unstyled={unstyled}\n data-checked={withContextProps.checked || checked || undefined}\n variant={variant}\n ref={rootRef}\n mod={mod}\n attributes={attributes}\n inert={rest.inert}\n {...styleProps}\n {...wrapperProps}\n >\n <Box {...getStyles('inner')} mod={{ 'data-label-position': labelPosition }}>\n <Box\n component=\"input\"\n id={uuid}\n ref={useMergedRef(inputRef, ref)}\n mod={{ error: !!error }}\n {...getStyles('input', { focusable: true, variant })}\n {...rest}\n {...withContextProps}\n disabled={finalDisabled}\n inert={rest.inert}\n type=\"checkbox\"\n onClick={(event) => {\n if (readOnly) {\n event.preventDefault();\n }\n\n onClick?.(event);\n }}\n />\n\n <Icon indeterminate={indeterminate} {...getStyles('icon')} />\n </Box>\n </InlineInput>\n );\n});\n\nCheckbox.classes = { ...classes, ...InlineInputClasses };\nCheckbox.varsResolver = varsResolver;\nCheckbox.displayName = '@mantine/core/Checkbox';\nCheckbox.Group = CheckboxGroup;\nCheckbox.Indicator = CheckboxIndicator;\nCheckbox.Card = CheckboxCard;\n\nexport namespace Checkbox {\n export type Props = CheckboxProps;\n export type StylesNames = CheckboxStylesNames;\n export type CssVariables = CheckboxCssVariables;\n export type Factory = CheckboxFactory;\n export type Variant = CheckboxVariant;\n export type IconComponent = CheckboxIconComponent;\n\n export namespace Group {\n export type Props = CheckboxGroupProps;\n export type StylesNames = CheckboxGroupStylesNames;\n export type Factory = CheckboxGroupFactory;\n }\n\n export namespace Indicator {\n export type Props = CheckboxIndicatorProps;\n export type StylesNames = CheckboxIndicatorStylesNames;\n export type CssVariables = CheckboxIndicatorCssVariables;\n export type Factory = CheckboxIndicatorFactory;\n export type Variant = CheckboxIndicatorVariant;\n }\n\n export namespace Card {\n export type Props = CheckboxCardProps;\n export type StylesNames = CheckboxCardStylesNames;\n export type CssVariables = CheckboxCardCssVariables;\n export type Factory = CheckboxCardFactory;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAM,eAAe;CACnB,eAAe;CACf,MAAMA,kBAAAA;CACN,iBAAiB;CACjB,SAAS;CACT,QAAQ;CACT;AAED,MAAM,eAAeC,6BAAAA,oBAClB,OAAO,EAAE,QAAQ,OAAO,MAAM,WAAW,SAAS,mBAAmB;CACpE,MAAM,cAAcC,0BAAAA,gBAAgB;EAAE,OAAO,SAAS,MAAM;EAAc;EAAO,CAAC;CAClF,MAAM,eACJ,YAAY,gBAAgB,YAAY,UAAU,KAAA,IAC9C,uBAAuB,YA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BAAAA"}
1
+ {"version":3,"file":"Checkbox.cjs","names":["CheckboxIcon","createVarsResolver","parseThemeColor","getSize","getRadius","getThemeColor","getAutoContrastValue","getContrastColor","factory","useProps","CheckboxGroupContext","useStyles","extractStyleProps","InlineInput","Box","classes","InlineInputClasses","CheckboxGroup","CheckboxIndicator","CheckboxCard"],"sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { use, useEffect, useRef } from 'react';\nimport { useId, useMergedRef } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getAutoContrastValue,\n getContrastColor,\n getRadius,\n getSize,\n getThemeColor,\n MantineColor,\n MantineRadius,\n MantineSize,\n parseThemeColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { InlineInput, InlineInputClasses, InlineInputStylesNames } from '../../utils/InlineInput';\nimport {\n CheckboxCard,\n type CheckboxCardProps,\n type CheckboxCardStylesNames,\n type CheckboxCardCssVariables,\n type CheckboxCardFactory,\n} from './CheckboxCard/CheckboxCard';\nimport {\n CheckboxGroup,\n CheckboxGroupContext,\n type CheckboxGroupProps,\n type CheckboxGroupStylesNames,\n type CheckboxGroupFactory,\n} from './CheckboxGroup/CheckboxGroup';\nimport {\n CheckboxIndicator,\n type CheckboxIndicatorProps,\n type CheckboxIndicatorStylesNames,\n type CheckboxIndicatorCssVariables,\n type CheckboxIndicatorFactory,\n type CheckboxIndicatorVariant,\n} from './CheckboxIndicator/CheckboxIndicator';\nimport { CheckboxIcon } from './CheckIcon';\nimport classes from './Checkbox.module.css';\nexport type CheckboxVariant = 'filled' | 'outline';\nexport type CheckboxStylesNames = 'icon' | 'inner' | 'input' | InlineInputStylesNames;\nexport type CheckboxCssVariables = {\n root: '--checkbox-size' | '--checkbox-radius' | '--checkbox-color' | '--checkbox-icon-color';\n};\n\nexport type CheckboxIconComponent = React.FC<{\n indeterminate: boolean | undefined;\n className: string;\n}>;\n\nexport interface CheckboxProps\n extends BoxProps, StylesApiProps<CheckboxFactory>, ElementProps<'input', 'size' | 'children'> {\n /** Unique input id */\n id?: string;\n\n /** `label` associated with the checkbox */\n label?: React.ReactNode;\n\n /** Key of `theme.colors` or any valid CSS color to set input background color in checked state @default theme.primaryColor */\n color?: MantineColor;\n\n /** Controls size of the component @default 'sm' */\n size?: MantineSize | (string & {});\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Props passed down to the root element */\n wrapperProps?: React.ComponentProps<'div'> & DataAttributes;\n\n /** Position of the label relative to the input @default 'right' */\n labelPosition?: 'left' | 'right';\n\n /** Description below the label */\n description?: React.ReactNode;\n\n /** Error message below the label */\n error?: React.ReactNode;\n\n /** Indeterminate state of the checkbox. If set, `checked` prop is dismissed. */\n indeterminate?: boolean;\n\n /** Icon for checked or indeterminate state */\n icon?: CheckboxIconComponent;\n\n /** Root element ref */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Key of `theme.colors` or any valid CSS color to set icon color. By default, depends on `theme.autoContrast`. */\n iconColor?: MantineColor;\n\n /** If set, adjusts icon color based on background color for `filled` variant */\n autoContrast?: boolean;\n\n /** If set, applies error styles to the checkbox when `error` prop is set @default true */\n withErrorStyles?: boolean;\n}\n\nexport type CheckboxFactory = Factory<{\n props: CheckboxProps;\n ref: HTMLInputElement;\n stylesNames: CheckboxStylesNames;\n vars: CheckboxCssVariables;\n variant: CheckboxVariant;\n staticComponents: {\n Group: typeof CheckboxGroup;\n Indicator: typeof CheckboxIndicator;\n Card: typeof CheckboxCard;\n };\n}>;\n\nconst defaultProps = {\n labelPosition: 'right',\n icon: CheckboxIcon,\n withErrorStyles: true,\n variant: 'filled',\n radius: 'sm',\n} satisfies Partial<CheckboxProps>;\n\nconst varsResolver = createVarsResolver<CheckboxFactory>(\n (theme, { radius, color, size, iconColor, variant, autoContrast }) => {\n const parsedColor = parseThemeColor({ color: color || theme.primaryColor, theme });\n const outlineColor =\n parsedColor.isThemeColor && parsedColor.shade === undefined\n ? `var(--mantine-color-${parsedColor.color}-outline)`\n : parsedColor.color;\n\n return {\n root: {\n '--checkbox-size': getSize(size, 'checkbox-size'),\n '--checkbox-radius': radius === undefined ? undefined : getRadius(radius),\n '--checkbox-color': variant === 'outline' ? outlineColor : getThemeColor(color, theme),\n '--checkbox-icon-color': iconColor\n ? getThemeColor(iconColor, theme)\n : getAutoContrastValue(autoContrast, theme)\n ? getContrastColor({ color, theme, autoContrast })\n : undefined,\n },\n };\n }\n);\n\nexport const Checkbox = factory<CheckboxFactory>((_props) => {\n const props = useProps('Checkbox', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n color,\n label,\n id,\n size,\n radius,\n wrapperProps,\n checked,\n labelPosition,\n description,\n error,\n disabled,\n variant,\n indeterminate,\n icon: Icon,\n rootRef,\n iconColor,\n onChange,\n autoContrast,\n mod,\n attributes,\n readOnly,\n onClick,\n withErrorStyles,\n ref,\n ...others\n } = props;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const ctx = use(CheckboxGroupContext);\n const _size = size || ctx?.size;\n\n const getStyles = useStyles<CheckboxFactory>({\n name: 'Checkbox',\n props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const uuid = useId(id);\n\n const withContextProps = {\n checked: ctx?.value.includes(rest.value as string) ?? checked,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n ctx?.onChange(event);\n onChange?.(event);\n },\n };\n\n const isDisabledByGroup = ctx?.isDisabled?.(rest.value as string) ?? false;\n const finalDisabled = disabled || isDisabledByGroup;\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = indeterminate || false;\n\n if (indeterminate) {\n inputRef.current.setAttribute('data-indeterminate', 'true');\n } else {\n inputRef.current.removeAttribute('data-indeterminate');\n }\n }\n }, [indeterminate]);\n\n return (\n <InlineInput\n {...getStyles('root')}\n __staticSelector=\"Checkbox\"\n __stylesApiProps={props}\n id={uuid}\n size={_size}\n labelPosition={labelPosition}\n label={label}\n description={description}\n error={error}\n disabled={finalDisabled}\n classNames={classNames}\n styles={styles}\n unstyled={unstyled}\n data-checked={withContextProps.checked || checked || undefined}\n variant={variant}\n ref={rootRef}\n mod={mod}\n attributes={attributes}\n inert={rest.inert}\n {...styleProps}\n {...wrapperProps}\n >\n <Box {...getStyles('inner')} mod={{ 'data-label-position': labelPosition }}>\n <Box\n component=\"input\"\n id={uuid}\n ref={useMergedRef(inputRef, ref)}\n mod={{ error: !!error, 'with-error-styles': withErrorStyles }}\n {...getStyles('input', { focusable: true, variant })}\n {...rest}\n {...withContextProps}\n disabled={finalDisabled}\n inert={rest.inert}\n type=\"checkbox\"\n onClick={(event) => {\n if (readOnly) {\n event.preventDefault();\n }\n\n onClick?.(event);\n }}\n />\n\n <Icon indeterminate={indeterminate} {...getStyles('icon')} />\n </Box>\n </InlineInput>\n );\n});\n\nCheckbox.classes = { ...classes, ...InlineInputClasses };\nCheckbox.varsResolver = varsResolver;\nCheckbox.displayName = '@mantine/core/Checkbox';\nCheckbox.Group = CheckboxGroup;\nCheckbox.Indicator = CheckboxIndicator;\nCheckbox.Card = CheckboxCard;\n\nexport namespace Checkbox {\n export type Props = CheckboxProps;\n export type StylesNames = CheckboxStylesNames;\n export type CssVariables = CheckboxCssVariables;\n export type Factory = CheckboxFactory;\n export type Variant = CheckboxVariant;\n export type IconComponent = CheckboxIconComponent;\n\n export namespace Group {\n export type Props = CheckboxGroupProps;\n export type StylesNames = CheckboxGroupStylesNames;\n export type Factory = CheckboxGroupFactory;\n }\n\n export namespace Indicator {\n export type Props = CheckboxIndicatorProps;\n export type StylesNames = CheckboxIndicatorStylesNames;\n export type CssVariables = CheckboxIndicatorCssVariables;\n export type Factory = CheckboxIndicatorFactory;\n export type Variant = CheckboxIndicatorVariant;\n }\n\n export namespace Card {\n export type Props = CheckboxCardProps;\n export type StylesNames = CheckboxCardStylesNames;\n export type CssVariables = CheckboxCardCssVariables;\n export type Factory = CheckboxCardFactory;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAM,eAAe;CACnB,eAAe;CACf,MAAMA,kBAAAA;CACN,iBAAiB;CACjB,SAAS;CACT,QAAQ;CACT;AAED,MAAM,eAAeC,6BAAAA,oBAClB,OAAO,EAAE,QAAQ,OAAO,MAAM,WAAW,SAAS,mBAAmB;CACpE,MAAM,cAAcC,0BAAAA,gBAAgB;EAAE,OAAO,SAAS,MAAM;EAAc;EAAO,CAAC;CAClF,MAAM,eACJ,YAAY,gBAAgB,YAAY,UAAU,KAAA,IAC9C,uBAAuB,YAAY,MAAM,aACzC,YAAY;AAElB,QAAO,EACL,MAAM;EACJ,mBAAmBC,iBAAAA,QAAQ,MAAM,gBAAgB;EACjD,qBAAqB,WAAW,KAAA,IAAY,KAAA,IAAYC,iBAAAA,UAAU,OAAO;EACzE,oBAAoB,YAAY,YAAY,eAAeC,wBAAAA,cAAc,OAAO,MAAM;EACtF,yBAAyB,YACrBA,wBAAAA,cAAc,WAAW,MAAM,GAC/BC,gCAAAA,qBAAqB,cAAc,MAAM,GACvCC,2BAAAA,iBAAiB;GAAE;GAAO;GAAO;GAAc,CAAC,GAChD,KAAA;EACP,EACF;EAEJ;AAED,MAAa,WAAWC,gBAAAA,SAA0B,WAAW;CAC3D,MAAM,QAAQC,kBAAAA,SAAS,YAAY,cAAc,OAAO;CACxD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,OACA,OACA,IACA,MACA,QACA,cACA,SACA,eACA,aACA,OACA,UACA,SACA,eACA,MAAM,MACN,SACA,WACA,UACA,cACA,KACA,YACA,UACA,SACA,iBACA,KACA,GAAG,WACD;CAEJ,MAAM,YAAA,GAAA,MAAA,QAAoC,KAAK;CAC/C,MAAM,OAAA,GAAA,MAAA,KAAUC,sBAAAA,qBAAqB;CACrC,MAAM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AAI,UAAU,SAAS;KAAE,WAAW;KAAM;KAAS,CAAC;IACpD,GAAI;IACJ,GAAI;IACJ,UAAU;IACV,OAAO,KAAK;IACZ,MAAK;IACL,UAAU,UAAU;AAClB,SAAI,SACF,OAAM,gBAAgB;AAGxB,eAAU,MAAM;;IAElB,CAAA,EAEF,iBAAA,GAAA,kBAAA,KAAC,MAAD;IAAqB;IAAe,GAAI,UAAU,OAAO;IAAI,CAAA,CACzD;;EACM,CAAA;EAEhB;AAEF,SAAS,UAAU;CAAE,GAAGC,wBAAAA;CAAS,GAAGC,oBAAAA;CAAoB;AACxD,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,QAAQC,sBAAAA;AACjB,SAAS,YAAYC,0BAAAA;AACrB,SAAS,OAAOC,qBAAAA"}
@@ -41,7 +41,11 @@ const varsResolver = require_create_vars_resolver.createVarsResolver((_, { size
41
41
  colorPreview: { "--ci-preview-size": require_get_size.getSize(size, "ci-preview-size") }
42
42
  }));
43
43
  const ColorInput = require_factory.factory((_props) => {
44
- const props = require_use_props.useProps("ColorInput", defaultProps, _props);
44
+ const props = require_use_props.useProps([
45
+ "Input",
46
+ "InputWrapper",
47
+ "ColorInput"
48
+ ], defaultProps, _props);
45
49
  const { classNames, styles, unstyled, disallowInput, fixOnBlur, popoverProps, withPreview, withEyeDropper, eyeDropperIcon, closeOnColorSwatchClick, eyeDropperButtonProps, value, defaultValue, onChange, onChangeEnd, onClick, onFocus, onBlur, inputProps, format = "hex", wrapperProps, readOnly, withPicker, swatches, disabled, leftSection, rightSection, swatchesPerRow, ...others } = require_use_input_props.useInputProps("ColorInput", defaultProps, _props);
46
50
  const getStyles = require_use_styles.useStyles({
47
51
  name: "ColorInput",
@@ -1 +1 @@
1
- {"version":3,"file":"ColorInput.cjs","names":["createVarsResolver","getSize","factory","useProps","useInputProps","useStyles","useResolvedStylesApi","ActionIcon","convertHsvaTo","parseColor","EyeDropperIcon","isColorValid","Input","Popover","ColorSwatch","classes","ColorPicker","InputBase"],"sources":["../../../src/components/ColorInput/ColorInput.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useDidUpdate, useEyeDropper, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport {\n __ColorPickerProps,\n ColorPicker,\n ColorPickerStylesNames,\n convertHsvaTo,\n isColorValid,\n parseColor,\n} from '../ColorPicker';\nimport { ColorSwatch } from '../ColorSwatch';\nimport { __BaseInputProps, __InputStylesNames, Input, InputVariant, useInputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Popover, PopoverProps } from '../Popover';\nimport { EyeDropperIcon } from './EyeDropperIcon';\nimport classes from './ColorInput.module.css';\n\nexport type ColorInputStylesNames =\n | 'dropdown'\n | 'eyeDropperButton'\n | 'eyeDropperIcon'\n | 'colorPreview'\n | ColorPickerStylesNames\n | __InputStylesNames;\n\nexport type ColorInputCssVariables = {\n eyeDropperIcon: '--ci-eye-dropper-icon-size';\n eyeDropperButton: '--ci-button-size';\n colorPreview: '--ci-preview-size';\n};\n\nexport interface ColorInputProps\n extends\n BoxProps,\n __BaseInputProps,\n __ColorPickerProps,\n StylesApiProps<ColorInputFactory>,\n ElementProps<'input', 'size' | 'onChange' | 'value' | 'defaultValue'> {\n /** If input is not allowed, the user can only pick value with color picker and swatches */\n disallowInput?: boolean;\n\n /** If set, the input value resets to the last known valid value when the input loses focus @default true */\n fixOnBlur?: boolean;\n\n /** Props passed down to the `Popover` component */\n popoverProps?: PopoverProps;\n\n /** If set, the preview color swatch is displayed in the left section of the input @default true */\n withPreview?: boolean;\n\n /** If set, the eye dropper button is displayed in the right section @default true */\n withEyeDropper?: boolean;\n\n /** An icon to replace the default eye dropper icon */\n eyeDropperIcon?: React.ReactNode;\n\n /** If set, the dropdown is closed when one of the color swatches is clicked @default false */\n closeOnColorSwatchClick?: boolean;\n\n /** Props passed down to the eye dropper button */\n eyeDropperButtonProps?: Record<string, any>;\n}\n\nexport type ColorInputFactory = Factory<{\n props: ColorInputProps;\n ref: HTMLInputElement;\n stylesNames: ColorInputStylesNames;\n vars: ColorInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n format: 'hex',\n fixOnBlur: true,\n withPreview: true,\n swatchesPerRow: 7,\n withPicker: true,\n popoverProps: { transitionProps: { transition: 'fade', duration: 0 } },\n withEyeDropper: true,\n size: 'sm',\n leftSectionPointerEvents: 'none',\n} satisfies Partial<ColorInputProps>;\n\nconst varsResolver = createVarsResolver<ColorInputFactory>((_, { size }) => ({\n eyeDropperIcon: {\n '--ci-eye-dropper-icon-size': getSize(size, 'ci-eye-dropper-icon-size'),\n },\n\n eyeDropperButton: {\n '--ci-button-size': getSize(size, 'ci-button-size'),\n },\n\n colorPreview: {\n '--ci-preview-size': getSize(size, 'ci-preview-size'),\n },\n}));\n\nexport const ColorInput = factory<ColorInputFactory>((_props) => {\n const props = useProps('ColorInput', defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n disallowInput,\n fixOnBlur,\n popoverProps,\n withPreview,\n withEyeDropper,\n eyeDropperIcon,\n closeOnColorSwatchClick,\n eyeDropperButtonProps,\n value,\n defaultValue,\n onChange,\n onChangeEnd,\n onClick,\n onFocus,\n onBlur,\n inputProps,\n format = 'hex',\n wrapperProps,\n readOnly,\n withPicker,\n swatches,\n disabled,\n leftSection,\n rightSection,\n swatchesPerRow,\n ...others\n } = useInputProps('ColorInput', defaultProps, _props);\n\n const getStyles = useStyles<ColorInputFactory>({\n name: 'ColorInput',\n props,\n classes,\n classNames,\n styles,\n unstyled,\n rootSelector: 'wrapper',\n vars: props.vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ColorInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [dropdownOpened, setDropdownOpened] = useState(false);\n const [lastValidValue, setLastValidValue] = useState('');\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\n\n const { supported: eyeDropperSupported, open: openEyeDropper } = useEyeDropper();\n\n const eyeDropper = (\n <ActionIcon\n {...eyeDropperButtonProps}\n {...getStyles('eyeDropperButton', {\n className: eyeDropperButtonProps?.className,\n style: eyeDropperButtonProps?.style,\n })}\n variant=\"subtle\"\n color=\"gray\"\n unstyled={unstyled}\n onClick={() =>\n openEyeDropper()\n .then((payload) => {\n if (payload?.sRGBHex) {\n const color = convertHsvaTo(format, parseColor(payload.sRGBHex));\n setValue(color);\n onChangeEnd?.(color);\n }\n })\n .catch(() => {})\n }\n >\n {eyeDropperIcon || <EyeDropperIcon {...getStyles('eyeDropperIcon')} />}\n </ActionIcon>\n );\n\n const handleInputFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setDropdownOpened(true);\n };\n\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n fixOnBlur && setValue(lastValidValue);\n onBlur?.(event);\n setDropdownOpened(false);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>) => {\n onClick?.(event);\n setDropdownOpened(true);\n };\n\n useEffect(() => {\n if (isColorValid(_value) || _value.trim() === '') {\n setLastValidValue(_value);\n }\n }, [_value]);\n\n useDidUpdate(() => {\n if (isColorValid(_value)) {\n setValue(convertHsvaTo(format, parseColor(_value)));\n }\n }, [format]);\n\n return (\n <Input.Wrapper\n {...wrapperProps}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"ColorInput\"\n >\n <Popover\n __staticSelector=\"ColorInput\"\n position=\"bottom-start\"\n offset={5}\n opened={dropdownOpened}\n {...popoverProps}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n withRoles={false}\n disabled={\n readOnly || (withPicker === false && (!Array.isArray(swatches) || swatches.length === 0))\n }\n >\n <Popover.Target>\n <Input<'input'>\n autoComplete=\"off\"\n {...others}\n {...inputProps}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n disabled={disabled}\n __staticSelector=\"ColorInput\"\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onClick={handleInputClick}\n spellCheck={false}\n value={_value}\n onChange={(event) => {\n const inputValue = event.currentTarget.value;\n setValue(inputValue);\n if (isColorValid(inputValue)) {\n onChangeEnd?.(convertHsvaTo(format, parseColor(inputValue)));\n }\n }}\n leftSection={\n leftSection ||\n (withPreview ? (\n <ColorSwatch\n color={isColorValid(_value) ? _value : '#fff'}\n size=\"var(--ci-preview-size)\"\n {...getStyles('colorPreview')}\n />\n ) : null)\n }\n readOnly={disallowInput || readOnly}\n pointer={disallowInput}\n unstyled={unstyled}\n rightSection={\n rightSection ||\n (withEyeDropper && !disabled && !readOnly && eyeDropperSupported ? eyeDropper : null)\n }\n />\n </Popover.Target>\n\n <Popover.Dropdown\n onMouseDown={(event) => event.preventDefault()}\n className={classes.dropdown}\n >\n <ColorPicker\n __staticSelector=\"ColorInput\"\n value={_value}\n onChange={setValue}\n onChangeEnd={onChangeEnd}\n format={format}\n swatches={swatches}\n swatchesPerRow={swatchesPerRow}\n withPicker={withPicker}\n size={inputProps.size}\n focusable={false}\n unstyled={unstyled}\n styles={resolvedStyles}\n classNames={resolvedClassNames}\n onColorSwatchClick={() => closeOnColorSwatchClick && setDropdownOpened(false)}\n attributes={wrapperProps.attributes}\n />\n </Popover.Dropdown>\n </Popover>\n </Input.Wrapper>\n );\n});\n\nColorInput.classes = InputBase.classes;\nColorInput.varsResolver = varsResolver;\nColorInput.displayName = '@mantine/core/ColorInput';\n\nexport namespace ColorInput {\n export type Props = ColorInputProps;\n export type StylesNames = ColorInputStylesNames;\n export type CssVariables = ColorInputCssVariables;\n export type Factory = ColorInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAM,eAAe;CACnB,QAAQ;CACR,WAAW;CACX,aAAa;CACb,gBAAgB;CAChB,YA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olver","getSize","factory","useProps","useInputProps","useStyles","useResolvedStylesApi","ActionIcon","convertHsvaTo","parseColor","EyeDropperIcon","isColorValid","Input","Popover","ColorSwatch","classes","ColorPicker","InputBase"],"sources":["../../../src/components/ColorInput/ColorInput.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useDidUpdate, useEyeDropper, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport {\n __ColorPickerProps,\n ColorPicker,\n ColorPickerStylesNames,\n convertHsvaTo,\n isColorValid,\n parseColor,\n} from '../ColorPicker';\nimport { ColorSwatch } from '../ColorSwatch';\nimport { __BaseInputProps, __InputStylesNames, Input, InputVariant, useInputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Popover, PopoverProps } from '../Popover';\nimport { EyeDropperIcon } from './EyeDropperIcon';\nimport classes from './ColorInput.module.css';\n\nexport type ColorInputStylesNames =\n | 'dropdown'\n | 'eyeDropperButton'\n | 'eyeDropperIcon'\n | 'colorPreview'\n | ColorPickerStylesNames\n | __InputStylesNames;\n\nexport type ColorInputCssVariables = {\n eyeDropperIcon: '--ci-eye-dropper-icon-size';\n eyeDropperButton: '--ci-button-size';\n colorPreview: '--ci-preview-size';\n};\n\nexport interface ColorInputProps\n extends\n BoxProps,\n __BaseInputProps,\n __ColorPickerProps,\n StylesApiProps<ColorInputFactory>,\n ElementProps<'input', 'size' | 'onChange' | 'value' | 'defaultValue'> {\n /** If input is not allowed, the user can only pick value with color picker and swatches */\n disallowInput?: boolean;\n\n /** If set, the input value resets to the last known valid value when the input loses focus @default true */\n fixOnBlur?: boolean;\n\n /** Props passed down to the `Popover` component */\n popoverProps?: PopoverProps;\n\n /** If set, the preview color swatch is displayed in the left section of the input @default true */\n withPreview?: boolean;\n\n /** If set, the eye dropper button is displayed in the right section @default true */\n withEyeDropper?: boolean;\n\n /** An icon to replace the default eye dropper icon */\n eyeDropperIcon?: React.ReactNode;\n\n /** If set, the dropdown is closed when one of the color swatches is clicked @default false */\n closeOnColorSwatchClick?: boolean;\n\n /** Props passed down to the eye dropper button */\n eyeDropperButtonProps?: Record<string, any>;\n}\n\nexport type ColorInputFactory = Factory<{\n props: ColorInputProps;\n ref: HTMLInputElement;\n stylesNames: ColorInputStylesNames;\n vars: ColorInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n format: 'hex',\n fixOnBlur: true,\n withPreview: true,\n swatchesPerRow: 7,\n withPicker: true,\n popoverProps: { transitionProps: { transition: 'fade', duration: 0 } },\n withEyeDropper: true,\n size: 'sm',\n leftSectionPointerEvents: 'none',\n} satisfies Partial<ColorInputProps>;\n\nconst varsResolver = createVarsResolver<ColorInputFactory>((_, { size }) => ({\n eyeDropperIcon: {\n '--ci-eye-dropper-icon-size': getSize(size, 'ci-eye-dropper-icon-size'),\n },\n\n eyeDropperButton: {\n '--ci-button-size': getSize(size, 'ci-button-size'),\n },\n\n colorPreview: {\n '--ci-preview-size': getSize(size, 'ci-preview-size'),\n },\n}));\n\nexport const ColorInput = factory<ColorInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'ColorInput'], defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n disallowInput,\n fixOnBlur,\n popoverProps,\n withPreview,\n withEyeDropper,\n eyeDropperIcon,\n closeOnColorSwatchClick,\n eyeDropperButtonProps,\n value,\n defaultValue,\n onChange,\n onChangeEnd,\n onClick,\n onFocus,\n onBlur,\n inputProps,\n format = 'hex',\n wrapperProps,\n readOnly,\n withPicker,\n swatches,\n disabled,\n leftSection,\n rightSection,\n swatchesPerRow,\n ...others\n } = useInputProps('ColorInput', defaultProps, _props);\n\n const getStyles = useStyles<ColorInputFactory>({\n name: 'ColorInput',\n props,\n classes,\n classNames,\n styles,\n unstyled,\n rootSelector: 'wrapper',\n vars: props.vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ColorInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [dropdownOpened, setDropdownOpened] = useState(false);\n const [lastValidValue, setLastValidValue] = useState('');\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\n\n const { supported: eyeDropperSupported, open: openEyeDropper } = useEyeDropper();\n\n const eyeDropper = (\n <ActionIcon\n {...eyeDropperButtonProps}\n {...getStyles('eyeDropperButton', {\n className: eyeDropperButtonProps?.className,\n style: eyeDropperButtonProps?.style,\n })}\n variant=\"subtle\"\n color=\"gray\"\n unstyled={unstyled}\n onClick={() =>\n openEyeDropper()\n .then((payload) => {\n if (payload?.sRGBHex) {\n const color = convertHsvaTo(format, parseColor(payload.sRGBHex));\n setValue(color);\n onChangeEnd?.(color);\n }\n })\n .catch(() => {})\n }\n >\n {eyeDropperIcon || <EyeDropperIcon {...getStyles('eyeDropperIcon')} />}\n </ActionIcon>\n );\n\n const handleInputFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setDropdownOpened(true);\n };\n\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n fixOnBlur && setValue(lastValidValue);\n onBlur?.(event);\n setDropdownOpened(false);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>) => {\n onClick?.(event);\n setDropdownOpened(true);\n };\n\n useEffect(() => {\n if (isColorValid(_value) || _value.trim() === '') {\n setLastValidValue(_value);\n }\n }, [_value]);\n\n useDidUpdate(() => {\n if (isColorValid(_value)) {\n setValue(convertHsvaTo(format, parseColor(_value)));\n }\n }, [format]);\n\n return (\n <Input.Wrapper\n {...wrapperProps}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"ColorInput\"\n >\n <Popover\n __staticSelector=\"ColorInput\"\n position=\"bottom-start\"\n offset={5}\n opened={dropdownOpened}\n {...popoverProps}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n withRoles={false}\n disabled={\n readOnly || (withPicker === false && (!Array.isArray(swatches) || swatches.length === 0))\n }\n >\n <Popover.Target>\n <Input<'input'>\n autoComplete=\"off\"\n {...others}\n {...inputProps}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n disabled={disabled}\n __staticSelector=\"ColorInput\"\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onClick={handleInputClick}\n spellCheck={false}\n value={_value}\n onChange={(event) => {\n const inputValue = event.currentTarget.value;\n setValue(inputValue);\n if (isColorValid(inputValue)) {\n onChangeEnd?.(convertHsvaTo(format, parseColor(inputValue)));\n }\n }}\n leftSection={\n leftSection ||\n (withPreview ? (\n <ColorSwatch\n color={isColorValid(_value) ? _value : '#fff'}\n size=\"var(--ci-preview-size)\"\n {...getStyles('colorPreview')}\n />\n ) : null)\n }\n readOnly={disallowInput || readOnly}\n pointer={disallowInput}\n unstyled={unstyled}\n rightSection={\n rightSection ||\n (withEyeDropper && !disabled && !readOnly && eyeDropperSupported ? eyeDropper : null)\n }\n />\n </Popover.Target>\n\n <Popover.Dropdown\n onMouseDown={(event) => event.preventDefault()}\n className={classes.dropdown}\n >\n <ColorPicker\n __staticSelector=\"ColorInput\"\n value={_value}\n onChange={setValue}\n onChangeEnd={onChangeEnd}\n format={format}\n swatches={swatches}\n swatchesPerRow={swatchesPerRow}\n withPicker={withPicker}\n size={inputProps.size}\n focusable={false}\n unstyled={unstyled}\n styles={resolvedStyles}\n classNames={resolvedClassNames}\n onColorSwatchClick={() => closeOnColorSwatchClick && setDropdownOpened(false)}\n attributes={wrapperProps.attributes}\n />\n </Popover.Dropdown>\n </Popover>\n </Input.Wrapper>\n );\n});\n\nColorInput.classes = InputBase.classes;\nColorInput.varsResolver = varsResolver;\nColorInput.displayName = '@mantine/core/ColorInput';\n\nexport namespace ColorInput {\n export type Props = ColorInputProps;\n export type StylesNames = ColorInputStylesNames;\n export type CssVariables = ColorInputCssVariables;\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a;KACzB,CAAA;IACe,CAAA,CACX;;EACI,CAAA;EAElB;AAEF,WAAW,UAAUC,kBAAAA,UAAU;AAC/B,WAAW,eAAe;AAC1B,WAAW,cAAc"}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ //#region packages/@mantine/core/src/components/Combobox/use-pills-reorder/move-pill.ts
3
+ function movePill(value, from, to, position) {
4
+ if (from === to) return value;
5
+ if (position === "before" && to === from + 1) return value;
6
+ if (position === "after" && to === from - 1) return value;
7
+ const result = value.slice();
8
+ const [item] = result.splice(from, 1);
9
+ let targetIndex = from < to ? to - 1 : to;
10
+ if (position === "after") targetIndex += 1;
11
+ result.splice(targetIndex, 0, item);
12
+ return result;
13
+ }
14
+ //#endregion
15
+ exports.movePill = movePill;
16
+
17
+ //# sourceMappingURL=move-pill.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-pill.cjs","names":[],"sources":["../../../../src/components/Combobox/use-pills-reorder/move-pill.ts"],"sourcesContent":["export type PillReorderPosition = 'before' | 'after';\n\nexport function movePill<T>(\n value: T[],\n from: number,\n to: number,\n position: PillReorderPosition\n): T[] {\n if (from === to) {\n return value;\n }\n\n if (position === 'before' && to === from + 1) {\n return value;\n }\n\n if (position === 'after' && to === from - 1) {\n return value;\n }\n\n const result = value.slice();\n const [item] = result.splice(from, 1);\n\n let targetIndex = from < to ? to - 1 : to;\n if (position === 'after') {\n targetIndex += 1;\n }\n\n result.splice(targetIndex, 0, item);\n return result;\n}\n"],"mappings":";;AAEA,SAAgB,SACd,OACA,MACA,IACA,UACK;AACL,KAAI,SAAS,GACX,QAAO;AAGT,KAAI,aAAa,YAAY,OAAO,OAAO,EACzC,QAAO;AAGT,KAAI,aAAa,WAAW,OAAO,OAAO,EACxC,QAAO;CAGT,MAAM,SAAS,MAAM,OAAO;CAC5B,MAAM,CAAC,QAAQ,OAAO,OAAO,MAAM,EAAE;CAErC,IAAI,cAAc,OAAO,KAAK,KAAK,IAAI;AACvC,KAAI,aAAa,QACf,gBAAe;AAGjB,QAAO,OAAO,aAAa,GAAG,KAAK;AACnC,QAAO"}
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ require("../../../_virtual/_rolldown/runtime.cjs");
3
+ const require_move_pill = require("./move-pill.cjs");
4
+ let react = require("react");
5
+ //#region packages/@mantine/core/src/components/Combobox/use-pills-reorder/use-pills-reorder.ts
6
+ const findSearchInput = (container) => {
7
+ const lastChild = container.lastElementChild;
8
+ if (!lastChild) return null;
9
+ if (lastChild instanceof HTMLInputElement) return lastChild;
10
+ return lastChild.querySelector("input");
11
+ };
12
+ const valuesMatch = (a, b) => {
13
+ if (a === b) return true;
14
+ if (a.length !== b.length) return false;
15
+ for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
16
+ return true;
17
+ };
18
+ function usePillsReorder({ value, onChange, enabled }) {
19
+ const dragStateRef = (0, react.useRef)({
20
+ draggedIndex: null,
21
+ currentDropTarget: null
22
+ });
23
+ const pendingFocusRef = (0, react.useRef)(null);
24
+ const containerRef = (0, react.useRef)(null);
25
+ const valueRef = (0, react.useRef)(value);
26
+ valueRef.current = value;
27
+ (0, react.useEffect)(() => {
28
+ const pending = pendingFocusRef.current;
29
+ if (!pending) return;
30
+ pendingFocusRef.current = null;
31
+ if (!valuesMatch(valueRef.current, pending.expectedValue)) return;
32
+ pending.container?.querySelector(`[data-mantine-pill-index="${pending.index}"]`)?.focus();
33
+ });
34
+ const setContainer = (0, react.useCallback)((node) => {
35
+ containerRef.current = node;
36
+ }, []);
37
+ const getListProps = () => {
38
+ if (!enabled) return {};
39
+ return { ref: setContainer };
40
+ };
41
+ const handleInputKeyDown = (event) => {
42
+ if (!enabled || event.key !== "ArrowLeft") return;
43
+ const input = event.currentTarget;
44
+ if (!(input.value.length === 0 || input.selectionStart === 0 && input.selectionEnd === 0)) return;
45
+ const container = containerRef.current;
46
+ if (!container) return;
47
+ const pills = container.querySelectorAll("[data-mantine-pill-index]");
48
+ if (pills.length === 0) return;
49
+ event.preventDefault();
50
+ pills[pills.length - 1].focus();
51
+ };
52
+ const getPillProps = (index) => {
53
+ if (!enabled) return;
54
+ return {
55
+ draggable: true,
56
+ tabIndex: -1,
57
+ "data-mantine-pill-index": index,
58
+ "aria-keyshortcuts": "Alt+ArrowLeft Alt+ArrowRight",
59
+ onMouseDown: (event) => {
60
+ if (event.button === 0) event.stopPropagation();
61
+ },
62
+ onDragStart: (event) => {
63
+ event.stopPropagation();
64
+ event.dataTransfer.effectAllowed = "move";
65
+ event.dataTransfer.setData("text/plain", String(index));
66
+ dragStateRef.current.draggedIndex = index;
67
+ const target = event.currentTarget;
68
+ const rect = target.getBoundingClientRect();
69
+ const ghost = target.cloneNode(true);
70
+ ghost.removeAttribute("data-dragging");
71
+ ghost.removeAttribute("data-drag-over");
72
+ ghost.style.position = "fixed";
73
+ ghost.style.top = "-9999px";
74
+ ghost.style.left = "-9999px";
75
+ ghost.style.width = `${rect.width}px`;
76
+ ghost.style.height = `${rect.height}px`;
77
+ ghost.style.pointerEvents = "none";
78
+ document.body.appendChild(ghost);
79
+ event.dataTransfer.setDragImage(ghost, event.clientX - rect.left, event.clientY - rect.top);
80
+ setTimeout(() => ghost.parentNode?.removeChild(ghost), 0);
81
+ requestAnimationFrame(() => {
82
+ target.setAttribute("data-dragging", "true");
83
+ });
84
+ },
85
+ onDragOver: (event) => {
86
+ const { draggedIndex } = dragStateRef.current;
87
+ if (draggedIndex === null || draggedIndex === index) return;
88
+ const target = event.currentTarget;
89
+ const rect = target.getBoundingClientRect();
90
+ const x = event.clientX - rect.left;
91
+ const position = (getComputedStyle(target).direction === "rtl" ? x > rect.width / 2 : x < rect.width / 2) ? "before" : "after";
92
+ event.preventDefault();
93
+ event.stopPropagation();
94
+ event.dataTransfer.dropEffect = "move";
95
+ const prevTarget = dragStateRef.current.currentDropTarget;
96
+ if (prevTarget && prevTarget !== target) prevTarget.removeAttribute("data-drag-over");
97
+ target.setAttribute("data-drag-over", position);
98
+ dragStateRef.current.currentDropTarget = target;
99
+ },
100
+ onDragLeave: (event) => {
101
+ const target = event.currentTarget;
102
+ const related = event.relatedTarget;
103
+ if (related && target.contains(related)) return;
104
+ target.removeAttribute("data-drag-over");
105
+ if (dragStateRef.current.currentDropTarget === target) dragStateRef.current.currentDropTarget = null;
106
+ },
107
+ onDrop: (event) => {
108
+ event.preventDefault();
109
+ event.stopPropagation();
110
+ const target = event.currentTarget;
111
+ const position = target.getAttribute("data-drag-over");
112
+ target.removeAttribute("data-drag-over");
113
+ const { draggedIndex } = dragStateRef.current;
114
+ if (draggedIndex !== null && position && draggedIndex !== index) {
115
+ const nextValue = require_move_pill.movePill(valueRef.current, draggedIndex, index, position);
116
+ if (nextValue !== valueRef.current) onChange(nextValue);
117
+ }
118
+ dragStateRef.current.draggedIndex = null;
119
+ dragStateRef.current.currentDropTarget = null;
120
+ },
121
+ onDragEnd: (event) => {
122
+ event.currentTarget.removeAttribute("data-dragging");
123
+ const prevTarget = dragStateRef.current.currentDropTarget;
124
+ if (prevTarget) prevTarget.removeAttribute("data-drag-over");
125
+ dragStateRef.current.draggedIndex = null;
126
+ dragStateRef.current.currentDropTarget = null;
127
+ },
128
+ onKeyDown: (event) => {
129
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
130
+ const target = event.currentTarget;
131
+ const movingForward = getComputedStyle(target).direction === "rtl" ? event.key === "ArrowLeft" : event.key === "ArrowRight";
132
+ const targetIndex = movingForward ? index + 1 : index - 1;
133
+ if (event.altKey) {
134
+ if (targetIndex < 0 || targetIndex >= valueRef.current.length) return;
135
+ event.preventDefault();
136
+ event.stopPropagation();
137
+ const position = movingForward ? "after" : "before";
138
+ const nextValue = require_move_pill.movePill(valueRef.current, index, targetIndex, position);
139
+ if (nextValue === valueRef.current) return;
140
+ pendingFocusRef.current = {
141
+ container: target.parentElement,
142
+ index: targetIndex,
143
+ expectedValue: nextValue
144
+ };
145
+ onChange(nextValue);
146
+ return;
147
+ }
148
+ if (targetIndex < 0) return;
149
+ const container = target.parentElement;
150
+ if (!container) return;
151
+ event.preventDefault();
152
+ event.stopPropagation();
153
+ if (targetIndex >= valueRef.current.length) {
154
+ findSearchInput(container)?.focus();
155
+ return;
156
+ }
157
+ container.querySelector(`[data-mantine-pill-index="${targetIndex}"]`)?.focus();
158
+ }
159
+ };
160
+ };
161
+ return {
162
+ getPillProps,
163
+ getListProps,
164
+ handleInputKeyDown
165
+ };
166
+ }
167
+ //#endregion
168
+ exports.usePillsReorder = usePillsReorder;
169
+
170
+ //# sourceMappingURL=use-pills-reorder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pills-reorder.cjs","names":["movePill"],"sources":["../../../../src/components/Combobox/use-pills-reorder/use-pills-reorder.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { movePill, PillReorderPosition } from './move-pill';\n\nexport interface PillReorderProps {\n draggable: boolean;\n tabIndex: number;\n 'data-mantine-pill-index': number;\n 'aria-keyshortcuts': string;\n onMouseDown: (event: React.MouseEvent<HTMLElement>) => void;\n onDragStart: (event: React.DragEvent<HTMLElement>) => void;\n onDragOver: (event: React.DragEvent<HTMLElement>) => void;\n onDragLeave: (event: React.DragEvent<HTMLElement>) => void;\n onDrop: (event: React.DragEvent<HTMLElement>) => void;\n onDragEnd: (event: React.DragEvent<HTMLElement>) => void;\n onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\nexport interface PillsReorderListProps {\n ref?: (node: HTMLDivElement | null) => void;\n}\n\nexport interface UsePillsReorderInput<T> {\n value: T[];\n onChange: (value: T[]) => void;\n enabled: boolean | undefined;\n}\n\ninterface PillDragState {\n draggedIndex: number | null;\n currentDropTarget: HTMLElement | null;\n}\n\ninterface PendingFocus<T> {\n container: HTMLElement | null;\n index: number;\n expectedValue: T[];\n}\n\nconst findSearchInput = (container: HTMLElement): HTMLInputElement | null => {\n const lastChild = container.lastElementChild;\n if (!lastChild) {\n return null;\n }\n if (lastChild instanceof HTMLInputElement) {\n return lastChild;\n }\n return lastChild.querySelector<HTMLInputElement>('input');\n};\n\nconst valuesMatch = <T>(a: T[], b: T[]): boolean => {\n if (a === b) {\n return true;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n};\n\nexport function usePillsReorder<T>({ value, onChange, enabled }: UsePillsReorderInput<T>) {\n const dragStateRef = useRef<PillDragState>({ draggedIndex: null, currentDropTarget: null });\n const pendingFocusRef = useRef<PendingFocus<T> | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const valueRef = useRef(value);\n valueRef.current = value;\n\n useEffect(() => {\n const pending = pendingFocusRef.current;\n if (!pending) {\n return;\n }\n pendingFocusRef.current = null;\n if (!valuesMatch(valueRef.current, pending.expectedValue)) {\n return;\n }\n pending.container\n ?.querySelector<HTMLElement>(`[data-mantine-pill-index=\"${pending.index}\"]`)\n ?.focus();\n });\n\n const setContainer = useCallback((node: HTMLDivElement | null) => {\n containerRef.current = node;\n }, []);\n\n const getListProps = (): PillsReorderListProps => {\n if (!enabled) {\n return {};\n }\n return { ref: setContainer };\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (!enabled || event.key !== 'ArrowLeft') {\n return;\n }\n\n const input = event.currentTarget;\n const caretAtStart =\n input.value.length === 0 || (input.selectionStart === 0 && input.selectionEnd === 0);\n if (!caretAtStart) {\n return;\n }\n\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n const pills = container.querySelectorAll<HTMLElement>('[data-mantine-pill-index]');\n if (pills.length === 0) {\n return;\n }\n\n event.preventDefault();\n pills[pills.length - 1].focus();\n };\n\n const getPillProps = (index: number): PillReorderProps | undefined => {\n if (!enabled) {\n return undefined;\n }\n\n return {\n draggable: true,\n tabIndex: -1,\n 'data-mantine-pill-index': index,\n 'aria-keyshortcuts': 'Alt+ArrowLeft Alt+ArrowRight',\n onMouseDown: (event) => {\n if (event.button === 0) {\n event.stopPropagation();\n }\n },\n onDragStart: (event) => {\n event.stopPropagation();\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setData('text/plain', String(index));\n dragStateRef.current.draggedIndex = index;\n\n const target = event.currentTarget;\n const rect = target.getBoundingClientRect();\n const ghost = target.cloneNode(true) as HTMLElement;\n ghost.removeAttribute('data-dragging');\n ghost.removeAttribute('data-drag-over');\n ghost.style.position = 'fixed';\n ghost.style.top = '-9999px';\n ghost.style.left = '-9999px';\n ghost.style.width = `${rect.width}px`;\n ghost.style.height = `${rect.height}px`;\n ghost.style.pointerEvents = 'none';\n document.body.appendChild(ghost);\n event.dataTransfer.setDragImage(ghost, event.clientX - rect.left, event.clientY - rect.top);\n\n setTimeout(() => ghost.parentNode?.removeChild(ghost), 0);\n\n requestAnimationFrame(() => {\n target.setAttribute('data-dragging', 'true');\n });\n },\n onDragOver: (event) => {\n const { draggedIndex } = dragStateRef.current;\n if (draggedIndex === null || draggedIndex === index) {\n return;\n }\n\n const target = event.currentTarget;\n const rect = target.getBoundingClientRect();\n const x = event.clientX - rect.left;\n const isRtl = getComputedStyle(target).direction === 'rtl';\n const isStart = isRtl ? x > rect.width / 2 : x < rect.width / 2;\n const position: PillReorderPosition = isStart ? 'before' : 'after';\n\n event.preventDefault();\n event.stopPropagation();\n event.dataTransfer.dropEffect = 'move';\n\n const prevTarget = dragStateRef.current.currentDropTarget;\n if (prevTarget && prevTarget !== target) {\n prevTarget.removeAttribute('data-drag-over');\n }\n\n target.setAttribute('data-drag-over', position);\n dragStateRef.current.currentDropTarget = target;\n },\n onDragLeave: (event) => {\n const target = event.currentTarget;\n const related = event.relatedTarget as Node | null;\n if (related && target.contains(related)) {\n return;\n }\n\n target.removeAttribute('data-drag-over');\n if (dragStateRef.current.currentDropTarget === target) {\n dragStateRef.current.currentDropTarget = null;\n }\n },\n onDrop: (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n const target = event.currentTarget;\n const position = target.getAttribute('data-drag-over') as PillReorderPosition | null;\n target.removeAttribute('data-drag-over');\n\n const { draggedIndex } = dragStateRef.current;\n if (draggedIndex !== null && position && draggedIndex !== index) {\n const nextValue = movePill(valueRef.current, draggedIndex, index, position);\n if (nextValue !== valueRef.current) {\n onChange(nextValue);\n }\n }\n\n dragStateRef.current.draggedIndex = null;\n dragStateRef.current.currentDropTarget = null;\n },\n onDragEnd: (event) => {\n const target = event.currentTarget;\n target.removeAttribute('data-dragging');\n\n const prevTarget = dragStateRef.current.currentDropTarget;\n if (prevTarget) {\n prevTarget.removeAttribute('data-drag-over');\n }\n\n dragStateRef.current.draggedIndex = null;\n dragStateRef.current.currentDropTarget = null;\n },\n onKeyDown: (event) => {\n if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {\n return;\n }\n\n const target = event.currentTarget;\n const isRtl = getComputedStyle(target).direction === 'rtl';\n const movingForward = isRtl ? event.key === 'ArrowLeft' : event.key === 'ArrowRight';\n const targetIndex = movingForward ? index + 1 : index - 1;\n\n if (event.altKey) {\n if (targetIndex < 0 || targetIndex >= valueRef.current.length) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n const position: PillReorderPosition = movingForward ? 'after' : 'before';\n const nextValue = movePill(valueRef.current, index, targetIndex, position);\n if (nextValue === valueRef.current) {\n return;\n }\n\n pendingFocusRef.current = {\n container: target.parentElement,\n index: targetIndex,\n expectedValue: nextValue,\n };\n onChange(nextValue);\n return;\n }\n\n if (targetIndex < 0) {\n return;\n }\n\n const container = target.parentElement;\n if (!container) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n if (targetIndex >= valueRef.current.length) {\n findSearchInput(container)?.focus();\n return;\n }\n\n container.querySelector<HTMLElement>(`[data-mantine-pill-index=\"${targetIndex}\"]`)?.focus();\n },\n };\n };\n\n return { getPillProps, getListProps, handleInputKeyDown };\n}\n"],"mappings":";;;;;AAsCA,MAAM,mBAAmB,cAAoD;CAC3E,MAAM,YAAY,UAAU;AAC5B,KAAI,CAAC,UACH,QAAO;AAET,KAAI,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,IAAI,QAAQ;AAExD,QAAI,MAAM,QAAQ;AAChB,SAAI,cAAc,KAAK,eAAe,SAAS,QAAQ,OACrD;AAGF,WAAM,gBAAgB;AACtB,WAAM,iBAAiB;KAEvB,MAAM,WAAgC,gBAAgB,UAAU;KAChE,MAAM,YAAYA,kBAAAA,SAAS,SAAS,SAAS,OAAO,aAAa,SAAS;AAC1E,SAAI,cAAc,SAAS,QACzB;AAGF,qBAAgB,UAAU;MACxB,WAAW,OAAO;MAClB,OAAO;MACP,eAAe;MAChB;AACD,cAAS,UAAU;AACnB;;AAGF,QAAI,cAAc,EAChB;IAGF,MAAM,YAAY,OAAO;AACzB,QAAI,CAAC,UACH;AAGF,UAAM,gBAAgB;AACtB,UAAM,iBAAiB;AAEvB,QAAI,eAAe,SAAS,QAAQ,QAAQ;AAC1C,qBAAgB,UAAU,EAAE,OAAO;AACnC;;AAGF,cAAU,cAA2B,6BAA6B,YAAY,IAAI,EAAE,OAAO;;GAE9F;;AAGH,QAAO;EAAE;EAAc;EAAc;EAAoB"}
@@ -24,7 +24,11 @@ const defaultProps = {
24
24
  size: "sm"
25
25
  };
26
26
  const FileInput = require_factory.genericFactory((_props) => {
27
- const props = require_use_props.useProps("FileInput", defaultProps, _props);
27
+ const props = require_use_props.useProps([
28
+ "Input",
29
+ "InputWrapper",
30
+ "FileInput"
31
+ ], defaultProps, _props);
28
32
  const { unstyled, vars, onChange, value, defaultValue, multiple, accept, name, form, valueComponent: ValueComponent, clearable, clearSectionMode, clearButtonProps, readOnly, capture, fileInputProps, rightSection, size, placeholder, component, resetRef: resetRefProp, classNames, styles, attributes, ...others } = props;
29
33
  const resetRef = (0, react.useRef)(null);
30
34
  const { resolvedClassNames, resolvedStyles } = require_use_resolved_styles_api.useResolvedStylesApi({
@@ -1 +1 @@
1
- {"version":3,"file":"FileInput.cjs","names":["genericFactory","useProps","useResolvedStylesApi","CloseButton","FileButton","InputBase","Input"],"sources":["../../../src/components/FileInput/FileInput.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n Factory,\n genericFactory,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport { CloseButton } from '../CloseButton';\nimport { FileButton } from '../FileButton';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n Input,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase/InputBase';\n\nexport interface FileInputProps<Multiple = false>\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<FileInputFactory>,\n ElementProps<'button', 'value' | 'defaultValue' | 'onChange' | 'placeholder'> {\n component?: any;\n\n /** Called when value changes */\n onChange?: (payload: Multiple extends true ? File[] : File | null) => void;\n\n /** Controlled component value */\n value?: Multiple extends true ? File[] : File | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Multiple extends true ? File[] : File | null;\n\n /** If set, user can pick more than one file @default false */\n multiple?: Multiple;\n\n /** File input accept attribute, for example, `\"image/png,image/jpeg\"` */\n accept?: string;\n\n /** Input name attribute */\n name?: string;\n\n /** Input form attribute */\n form?: string;\n\n /** Value renderer. By default, displays file name. */\n valueComponent?: React.FC<{ value: null | File | File[] }>;\n\n /** If set, the clear button is displayed in the right section @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?: React.ComponentProps<'button'>;\n\n /** If set, the input value cannot be changed */\n readOnly?: boolean;\n\n /** Specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the accept attribute. */\n capture?: boolean | 'user' | 'environment';\n\n /** Props passed down to the hidden `input[type=\"file\"]` */\n fileInputProps?: React.ComponentProps<'input'>;\n\n /** Input placeholder */\n placeholder?: React.ReactNode;\n\n /** Reference of the function that should be called when value changes to null or empty array */\n resetRef?: React.Ref<() => void>;\n}\n\nexport type FileInputFactory = Factory<{\n props: FileInputProps;\n ref: HTMLButtonElement;\n stylesNames: __InputStylesNames | 'placeholder';\n variant: InputVariant;\n signature: <Multiple extends boolean = false>(\n props: FileInputProps<Multiple>\n ) => React.JSX.Element;\n}>;\n\nconst DefaultValue: FileInputProps['valueComponent'] = ({ value }) => (\n <div style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {Array.isArray(value) ? value.map((file) => file.name).join(', ') : value?.name}\n </div>\n);\n\nconst defaultProps = {\n valueComponent: DefaultValue,\n size: 'sm',\n} satisfies Partial<FileInputProps>;\n\nexport const FileInput = genericFactory<FileInputFactory>((_props) => {\n const props = useProps('FileInput', defaultProps, _props);\n const {\n unstyled,\n vars,\n onChange,\n value,\n defaultValue,\n multiple,\n accept,\n name,\n form,\n valueComponent: ValueComponent,\n clearable,\n clearSectionMode,\n clearButtonProps,\n readOnly,\n capture,\n fileInputProps,\n rightSection,\n size,\n placeholder,\n component,\n resetRef: resetRefProp,\n classNames,\n styles,\n attributes,\n ...others\n } = props;\n\n const resetRef = useRef<() => void>(null);\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<FileInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [_value, setValue] = useUncontrolled<null | File | File[]>({\n value,\n defaultValue,\n onChange: onChange as any,\n finalValue: multiple ? [] : null,\n });\n\n const hasValue = Array.isArray(_value) ? _value.length !== 0 : _value !== null;\n\n const clearButton = (\n <CloseButton\n {...clearButtonProps}\n variant=\"subtle\"\n onClick={() => setValue(multiple ? [] : null)}\n size={size}\n unstyled={unstyled}\n />\n );\n\n const _clearable = clearable && hasValue && !readOnly;\n\n useEffect(() => {\n if ((Array.isArray(_value) && _value.length === 0) || _value === null) {\n resetRef.current?.();\n }\n }, [_value]);\n\n return (\n <FileButton\n onChange={setValue}\n multiple={multiple}\n accept={accept}\n name={name}\n form={form}\n resetRef={useMergedRef(resetRef, resetRefProp)}\n disabled={readOnly}\n capture={capture}\n inputProps={fileInputProps}\n >\n {(fileButtonProps) => (\n <InputBase\n component={component || 'button'}\n rightSection={rightSection}\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n {...fileButtonProps}\n {...others}\n __staticSelector=\"FileInput\"\n multiline\n type=\"button\"\n pointer\n __stylesApiProps={props}\n unstyled={unstyled}\n size={size}\n classNames={classNames}\n styles={styles}\n attributes={attributes}\n >\n {!hasValue ? (\n <Input.Placeholder\n __staticSelector=\"FileInput\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n attributes={attributes}\n >\n {placeholder}\n </Input.Placeholder>\n ) : (\n <ValueComponent value={_value} />\n )}\n </InputBase>\n )}\n </FileButton>\n );\n});\n\nFileInput.classes = InputBase.classes;\nFileInput.displayName = '@mantine/core/FileInput';\n\nexport namespace FileInput {\n export type Props<Multiple extends boolean = false> = FileInputProps<Multiple>;\n export type Factory = FileInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AAyFA,MAAM,gBAAkD,EAAE,YACxD,iBAAA,GAAA,kBAAA,KAAC,OAAD;CAAK,OAAO;EAAE,UAAU;EAAU,cAAc;EAAY,YAAY;EAAU;WAC/E,MAAM,QAAQ,MAAM,GAAG,MAAM,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,KAAK,GAAG,OAAO;CACvE,CAAA;AAGR,MAAM,eAAe;CACnB,gBAAgB;CAChB,MAAM;CACP;AAED,MAAa,YAAYA,gBAAAA,gBAAkC,WAAW;CACpE,MAAM,QAAQC,kBAAAA,SAAS,aAAa,cAAc,OAAO;CACzD,MAAM,EACJ,UACA,MACA,UACA,OACA,cACA,UACA,QACA,MACA,MACA,gBAAgB,gBAChB,WACA,kBACA,kBACA,UACA,SACA,gBACA,cACA,MACA,aACA,WACA,UAAU,cACV,YACA,QACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAA,GAAA,MAAA,QAA8B,KAAK;CACzC,MAAM,EAAE,oBAAoB,mBAAmBC,gCAAAA,qBAAuC;EACpF;EACA;EACA;EACD,CAAC;CAEF,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAAkD;EAC/D;EACA;EACU;EACV,YAAY,WAAW,EAAE,GAAG;EAC7B,CAAC;CAEF,MAAM,WAAW,MAAM,QAAQ,OAAO,GAAG,OAAO,WAAW,IAAI,WAAW;CAE1E,MAAM,cACJ,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,aAAD;EACE,GAAI;EACJ,SAAQ;EACR,eAAe,SAAS,WAAW,EAAE,GAAG,KAAK;EACvC;EACI;EACV,CAAA;CAGJ,MAAM,aAAa,aAAa,YAAY,CAAC;AAE7C,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAK,MAAM,QAAQ,OAAO,IAAI,OAAO,WAAW,KAAM,WAAW,KAC/D,UAAS,WAAW;IAErB,CAAC,OAAO,CAAC;AAEZ,QACE,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,YAAD;EACE,UAAU;EACA;EACF;EACF;EACA;EACN,WAAA,GAAA,eAAA,cAAuB,UAAU,aAAa;EAC9C,UAAU;EACD;EACT,YAAY;aAEV,oBACA,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;GACE,WAAW,aAAa;GACV;GACd,gBAAgB;GAChB,aAAa;GACb,oBAAoB;GACpB,GAAI;GACJ,GAAI;GACJ,kBAAiB;GACjB,WAAA;GACA,MAAK;GACL,SAAA;GACA,kBAAkB;GACR;GACJ;GACM;GACJ;GACI;aAEX,CAAC,WACA,iBAAA,GAAA,kBAAA,KAACC,cAAAA,MAAM,aAAP;IACE,kBAAiB;IACjB,YAAY;IACZ,QAAQ;IACI;cAEX;IACiB,CAAA,GAEpB,iBAAA,GAAA,kBAAA,KAAC,gBAAD,EAAgB,OAAO,QAAU,CAAA;GAEzB,CAAA;EAEH,CAAA;EAEf;AAEF,UAAU,UAAUD,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
1
+ {"version":3,"file":"FileInput.cjs","names":["genericFactory","useProps","useResolvedStylesApi","CloseButton","FileButton","InputBase","Input"],"sources":["../../../src/components/FileInput/FileInput.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n Factory,\n genericFactory,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n} from '../../core';\nimport { CloseButton } from '../CloseButton';\nimport { FileButton } from '../FileButton';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n Input,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase/InputBase';\n\nexport interface FileInputProps<Multiple = false>\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<FileInputFactory>,\n ElementProps<'button', 'value' | 'defaultValue' | 'onChange' | 'placeholder'> {\n component?: any;\n\n /** Called when value changes */\n onChange?: (payload: Multiple extends true ? File[] : File | null) => void;\n\n /** Controlled component value */\n value?: Multiple extends true ? File[] : File | null;\n\n /** Uncontrolled component default value */\n defaultValue?: Multiple extends true ? File[] : File | null;\n\n /** If set, user can pick more than one file @default false */\n multiple?: Multiple;\n\n /** File input accept attribute, for example, `\"image/png,image/jpeg\"` */\n accept?: string;\n\n /** Input name attribute */\n name?: string;\n\n /** Input form attribute */\n form?: string;\n\n /** Value renderer. By default, displays file name. */\n valueComponent?: React.FC<{ value: null | File | File[] }>;\n\n /** If set, the clear button is displayed in the right section @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?: React.ComponentProps<'button'>;\n\n /** If set, the input value cannot be changed */\n readOnly?: boolean;\n\n /** Specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the accept attribute. */\n capture?: boolean | 'user' | 'environment';\n\n /** Props passed down to the hidden `input[type=\"file\"]` */\n fileInputProps?: React.ComponentProps<'input'>;\n\n /** Input placeholder */\n placeholder?: React.ReactNode;\n\n /** Reference of the function that should be called when value changes to null or empty array */\n resetRef?: React.Ref<() => void>;\n}\n\nexport type FileInputFactory = Factory<{\n props: FileInputProps;\n ref: HTMLButtonElement;\n stylesNames: __InputStylesNames | 'placeholder';\n variant: InputVariant;\n signature: <Multiple extends boolean = false>(\n props: FileInputProps<Multiple>\n ) => React.JSX.Element;\n}>;\n\nconst DefaultValue: FileInputProps['valueComponent'] = ({ value }) => (\n <div style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {Array.isArray(value) ? value.map((file) => file.name).join(', ') : value?.name}\n </div>\n);\n\nconst defaultProps = {\n valueComponent: DefaultValue,\n size: 'sm',\n} satisfies Partial<FileInputProps>;\n\nexport const FileInput = genericFactory<FileInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'FileInput'], defaultProps, _props);\n const {\n unstyled,\n vars,\n onChange,\n value,\n defaultValue,\n multiple,\n accept,\n name,\n form,\n valueComponent: ValueComponent,\n clearable,\n clearSectionMode,\n clearButtonProps,\n readOnly,\n capture,\n fileInputProps,\n rightSection,\n size,\n placeholder,\n component,\n resetRef: resetRefProp,\n classNames,\n styles,\n attributes,\n ...others\n } = props;\n\n const resetRef = useRef<() => void>(null);\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<FileInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [_value, setValue] = useUncontrolled<null | File | File[]>({\n value,\n defaultValue,\n onChange: onChange as any,\n finalValue: multiple ? [] : null,\n });\n\n const hasValue = Array.isArray(_value) ? _value.length !== 0 : _value !== null;\n\n const clearButton = (\n <CloseButton\n {...clearButtonProps}\n variant=\"subtle\"\n onClick={() => setValue(multiple ? [] : null)}\n size={size}\n unstyled={unstyled}\n />\n );\n\n const _clearable = clearable && hasValue && !readOnly;\n\n useEffect(() => {\n if ((Array.isArray(_value) && _value.length === 0) || _value === null) {\n resetRef.current?.();\n }\n }, [_value]);\n\n return (\n <FileButton\n onChange={setValue}\n multiple={multiple}\n accept={accept}\n name={name}\n form={form}\n resetRef={useMergedRef(resetRef, resetRefProp)}\n disabled={readOnly}\n capture={capture}\n inputProps={fileInputProps}\n >\n {(fileButtonProps) => (\n <InputBase\n component={component || 'button'}\n rightSection={rightSection}\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n {...fileButtonProps}\n {...others}\n __staticSelector=\"FileInput\"\n multiline\n type=\"button\"\n pointer\n __stylesApiProps={props}\n unstyled={unstyled}\n size={size}\n classNames={classNames}\n styles={styles}\n attributes={attributes}\n >\n {!hasValue ? (\n <Input.Placeholder\n __staticSelector=\"FileInput\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n attributes={attributes}\n >\n {placeholder}\n </Input.Placeholder>\n ) : (\n <ValueComponent value={_value} />\n )}\n </InputBase>\n )}\n </FileButton>\n );\n});\n\nFileInput.classes = InputBase.classes;\nFileInput.displayName = '@mantine/core/FileInput';\n\nexport namespace FileInput {\n export type Props<Multiple extends boolean = false> = FileInputProps<Multiple>;\n export type Factory = FileInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AAyFA,MAAM,gBAAkD,EAAE,YACxD,iBAAA,GAAA,kBAAA,KAAC,OAAD;CAAK,OAAO;EAAE,UAAU;EAAU,cAAc;EAAY,YAAY;EAAU;WAC/E,MAAM,QAAQ,MAAM,GAAG,MAAM,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,KAAK,GAAG,OAAO;CACvE,CAAA;AAGR,MAAM,eAAe;CACnB,gBAAgB;CAChB,MAAM;CACP;AAED,MAAa,YAAYA,gBAAAA,gBAAkC,WAAW;CACpE,MAAM,QAAQC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;EAAY,EAAE,cAAc,OAAO;CACpF,MAAM,EACJ,UACA,MACA,UACA,OACA,cACA,UACA,QACA,MACA,MACA,gBAAgB,gBAChB,WACA,kBACA,kBACA,UACA,SACA,gBACA,cACA,MACA,aACA,WACA,UAAU,cACV,YACA,QACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAA,GA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AU;AAC9B,UAAU,cAAc"}
@@ -3,7 +3,11 @@ const require_use_props = require("../../core/MantineProvider/use-props/use-prop
3
3
  const require_extract_style_props = require("../../core/Box/style-props/extract-style-props/extract-style-props.cjs");
4
4
  //#region packages/@mantine/core/src/components/Input/use-input-props.ts
5
5
  function useInputProps(component, defaultProps, _props) {
6
- const props = require_use_props.useProps(component, defaultProps, _props);
6
+ const props = require_use_props.useProps([
7
+ "Input",
8
+ "InputWrapper",
9
+ component
10
+ ], defaultProps, _props);
7
11
  const { label, description, error, required, classNames, styles, className, unstyled, __staticSelector, __stylesApiProps, errorProps, labelProps, descriptionProps, wrapperProps: _wrapperProps, id, size, style, inputContainer, inputWrapperOrder, withAsterisk, variant, vars, mod, attributes, ...others } = props;
8
12
  const { styleProps, rest } = require_extract_style_props.extractStyleProps(others);
9
13
  const wrapperProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"use-input-props.cjs","names":["useProps","extractStyleProps"],"sources":["../../../src/components/Input/use-input-props.ts"],"sourcesContent":["import { BoxProps, extractStyleProps, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps } from './Input';\n\ninterface BaseProps\n extends __BaseInputProps, BoxProps, StylesApiProps<{ props: any; stylesNames: string }> {\n __staticSelector?: string;\n __stylesApiProps?: Record<string, any>;\n id?: string;\n}\n\nexport function useInputProps<T extends BaseProps, U extends Partial<T> | null>(\n component: string,\n defaultProps: U,\n _props: T\n) {\n const props = useProps<T, U>(component, defaultProps, _props);\n const {\n label,\n description,\n error,\n required,\n classNames,\n styles,\n className,\n unstyled,\n __staticSelector,\n __stylesApiProps,\n errorProps,\n labelProps,\n descriptionProps,\n wrapperProps: _wrapperProps,\n id,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n vars,\n mod,\n attributes,\n ...others\n } = props;\n\n const { styleProps, rest } = extractStyleProps(others);\n\n const wrapperProps = {\n label,\n description,\n error,\n required,\n classNames,\n className,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n errorProps,\n labelProps,\n descriptionProps,\n unstyled,\n styles,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n id,\n mod,\n attributes,\n ..._wrapperProps,\n };\n\n return {\n ...rest,\n classNames,\n styles,\n unstyled,\n wrapperProps: { ...wrapperProps, ...styleProps } as typeof wrapperProps & BoxProps,\n inputProps: {\n required,\n classNames,\n styles,\n unstyled,\n size,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n error,\n variant,\n id,\n attributes,\n },\n };\n}\n"],"mappings":";;;;AAUA,SAAgB,cACd,WACA,cACA,QACA;CACA,MAAM,QAAQA,kBAAAA,SAAe,WAAW,cAAc,OAAO;CAC7D,MAAM,EACJ,OACA,aACA,OACA,UACA,YACA,QACA,WACA,UACA,kBACA,kBACA,YACA,YACA,kBACA,cAAc,eACd,IACA,MACA,OACA,gBACA,mBACA,cACA,SACA,MACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,EAAE,YAAY,SAASC,4BAAAA,kBAAkB,OAAO;CAEtD,MAAM,eAAe;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAkB,oBAAoB;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;EACJ;AAED,QAAO;EACL,GAAG;EACH;EACA;EACA;EACA,cAAc;GAAE,GAAG;GAAc,GAAG;GAAY;EAChD,YAAY;GACV;GACA;GACA;GACA;GACA;GACA;GACA,kBAAkB,oBAAoB;GACtC;GACA;GACA;GACA;GACD;EACF"}
1
+ {"version":3,"file":"use-input-props.cjs","names":["useProps","extractStyleProps"],"sources":["../../../src/components/Input/use-input-props.ts"],"sourcesContent":["import { BoxProps, extractStyleProps, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps } from './Input';\n\ninterface BaseProps\n extends __BaseInputProps, BoxProps, StylesApiProps<{ props: any; stylesNames: string }> {\n __staticSelector?: string;\n __stylesApiProps?: Record<string, any>;\n id?: string;\n}\n\nexport function useInputProps<T extends BaseProps, U extends Partial<T> | null>(\n component: string,\n defaultProps: U,\n _props: T\n) {\n const props = useProps<T, U>(['Input', 'InputWrapper', component], defaultProps, _props);\n const {\n label,\n description,\n error,\n required,\n classNames,\n styles,\n className,\n unstyled,\n __staticSelector,\n __stylesApiProps,\n errorProps,\n labelProps,\n descriptionProps,\n wrapperProps: _wrapperProps,\n id,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n vars,\n mod,\n attributes,\n ...others\n } = props;\n\n const { styleProps, rest } = extractStyleProps(others);\n\n const wrapperProps = {\n label,\n description,\n error,\n required,\n classNames,\n className,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n errorProps,\n labelProps,\n descriptionProps,\n unstyled,\n styles,\n size,\n style,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n variant,\n id,\n mod,\n attributes,\n ..._wrapperProps,\n };\n\n return {\n ...rest,\n classNames,\n styles,\n unstyled,\n wrapperProps: { ...wrapperProps, ...styleProps } as typeof wrapperProps & BoxProps,\n inputProps: {\n required,\n classNames,\n styles,\n unstyled,\n size,\n __staticSelector,\n __stylesApiProps: __stylesApiProps || props,\n error,\n variant,\n id,\n attributes,\n },\n };\n}\n"],"mappings":";;;;AAUA,SAAgB,cACd,WACA,cACA,QACA;CACA,MAAM,QAAQA,kBAAAA,SAAe;EAAC;EAAS;EAAgB;EAAU,EAAE,cAAc,OAAO;CACxF,MAAM,EACJ,OACA,aACA,OACA,UACA,YACA,QACA,WACA,UACA,kBACA,kBACA,YACA,YACA,kBACA,cAAc,eACd,IACA,MACA,OACA,gBACA,mBACA,cACA,SACA,MACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,EAAE,YAAY,SAASC,4BAAAA,kBAAkB,OAAO;CAEtD,MAAM,eAAe;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAkB,oBAAoB;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;EACJ;AAED,QAAO;EACL,GAAG;EACH;EACA;EACA;EACA,cAAc;GAAE,GAAG;GAAc,GAAG;GAAY;EAChD,YAAY;GACV;GACA;GACA;GACA;GACA;GACA;GACA,kBAAkB,oBAAoB;GACtC;GACA;GACA;GACA;GACD;EACF"}
@@ -12,11 +12,14 @@ let react_jsx_runtime = require("react/jsx-runtime");
12
12
  const defaultProps = {
13
13
  serialize: JSON.stringify,
14
14
  deserialize: JSON.parse,
15
- size: "sm",
16
15
  indentSpaces: 2
17
16
  };
18
17
  const JsonInput = require_factory.factory((props) => {
19
- const { value, defaultValue, onChange, formatOnBlur, validationError, serialize, deserialize, onFocus, onBlur, readOnly, error, indentSpaces, ...others } = require_use_props.useProps("JsonInput", defaultProps, props);
18
+ const { value, defaultValue, onChange, formatOnBlur, validationError, serialize, deserialize, onFocus, onBlur, readOnly, error, indentSpaces, ...others } = require_use_props.useProps([
19
+ "Input",
20
+ "InputWrapper",
21
+ "JsonInput"
22
+ ], defaultProps, props);
20
23
  const [_value, setValue] = (0, _mantine_hooks.useUncontrolled)({
21
24
  value,
22
25
  defaultValue,
@@ -1 +1 @@
1
- {"version":3,"file":"JsonInput.cjs","names":["factory","useProps","validateJson","Textarea","InputBase"],"sources":["../../../src/components/JsonInput/JsonInput.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useUncontrolled } from '@mantine/hooks';\nimport { factory, Factory, useProps } from '../../core';\nimport { __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Textarea, TextareaProps } from '../Textarea';\nimport { validateJson } from './validate-json/validate-json';\n\nexport interface JsonInputProps extends Omit<TextareaProps, 'onChange'> {\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Determines whether the value should be formatted on blur @default false */\n formatOnBlur?: boolean;\n\n /** Error message shown when the input value is invalid JSON (checked on blur). If not provided, a generic error state is shown. Takes precedence over the `error` prop when validation fails. */\n validationError?: React.ReactNode;\n\n /** Function to serialize value into a string for formatting. Called with (value, null, 2) where 2 is the indentation level. @default JSON.stringify */\n serialize?: typeof JSON.stringify;\n\n /** Function to deserialize string value for formatting and validation. Must throw an error if the string is invalid JSON. @default JSON.parse */\n deserialize?: typeof JSON.parse;\n\n /** Number of spaces to use as white space for formatting. Passed as the third argument to `serialize` function. @default 2 */\n indentSpaces?: number;\n}\n\nexport type JsonInputFactory = Factory<{\n props: JsonInputProps;\n ref: HTMLTextAreaElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {\n serialize: JSON.stringify,\n deserialize: JSON.parse,\n size: 'sm',\n indentSpaces: 2,\n} satisfies Partial<JsonInputProps>;\n\nexport const JsonInput = factory<JsonInputFactory>((props) => {\n const {\n value,\n defaultValue,\n onChange,\n formatOnBlur,\n validationError,\n serialize,\n deserialize,\n onFocus,\n onBlur,\n readOnly,\n error,\n indentSpaces,\n ...others\n } = useProps('JsonInput', defaultProps, props);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\n\n const [valid, setValid] = useState(validateJson(_value, deserialize));\n\n const handleFocus = (event: React.FocusEvent<HTMLTextAreaElement>) => {\n onFocus?.(event);\n setValid(true);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLTextAreaElement>) => {\n onBlur?.(event);\n const isValid = validateJson(event.currentTarget.value, deserialize);\n formatOnBlur &&\n !readOnly &&\n isValid &&\n event.currentTarget.value.trim() !== '' &&\n setValue(serialize(deserialize(event.currentTarget.value), null, indentSpaces));\n setValid(isValid);\n };\n\n return (\n <Textarea\n value={_value}\n onChange={(event) => setValue(event.currentTarget.value)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n readOnly={readOnly}\n {...others}\n autoComplete=\"off\"\n __staticSelector=\"JsonInput\"\n error={valid ? error : validationError || true}\n data-monospace\n />\n );\n});\n\nJsonInput.classes = InputBase.classes;\nJsonInput.displayName = '@mantine/core/JsonInput';\n\nexport namespace JsonInput {\n export type Props = JsonInputProps;\n export type Factory = JsonInputFactory;\n}\n"],"mappings":";;;;;;;;;;;AAwCA,MAAM,eAAe;CACnB,WAAW,KAAK;CAChB,aAAa,KAAK;CAClB,MAAM;CACN,cAAc;CACf;AAED,MAAa,YAAYA,gBAAAA,SAA2B,UAAU;CAC5D,MAAM,EACJ,OACA,cACA,UACA,cACA,iBACA,WACA,aACA,SACA,QACA,UACA,OACA,cACA,GAAG,WACDC,kBAAAA,SAAS,aAAa,cAAc,MAAM;CAE9C,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAA4B;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqBC,sBAAAA,aAAa,QAAQ,YAAY,CAAC;CAErE,MAAM,eAAe,UAAiD;AACpE,YAAU,MAAM;AAChB,WAAS,KAAK;;CAGhB,MAAM,cAAc,UAAiD;AACnE,WAAS,MAAM;EACf,MAAM,UAAUA,sBAAAA,aAAa,MAAM,cAAc,OAAO,YAAY;AACpE,kBACE,CAAC,YACD,WACA,MAAM,cAAc,MAAM,MAAM,KAAK,MACrC,SAAS,UAAU,YAAY,MAAM,cAAc,MAAM,EAAE,MAAM,aAAa,CAAC;AACjF,WAAS,QAAQ;;AAGnB,QACE,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,UAAD;EACE,OAAO;EACP,WAAW,UAAU,SAAS,MAAM,cAAc,MAAM;EACxD,SAAS;EACT,QAAQ;EACE;EACV,GAAI;EACJ,cAAa;EACb,kBAAiB;EACjB,OAAO,QAAQ,QAAQ,mBAAmB;EAC1C,kBAAA;EACA,CAAA;EAEJ;AAEF,UAAU,UAAUC,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
1
+ {"version":3,"file":"JsonInput.cjs","names":["factory","useProps","validateJson","Textarea","InputBase"],"sources":["../../../src/components/JsonInput/JsonInput.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useUncontrolled } from '@mantine/hooks';\nimport { factory, Factory, useProps } from '../../core';\nimport { __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Textarea, TextareaProps } from '../Textarea';\nimport { validateJson } from './validate-json/validate-json';\n\nexport interface JsonInputProps extends Omit<TextareaProps, 'onChange'> {\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Determines whether the value should be formatted on blur @default false */\n formatOnBlur?: boolean;\n\n /** Error message shown when the input value is invalid JSON (checked on blur). If not provided, a generic error state is shown. Takes precedence over the `error` prop when validation fails. */\n validationError?: React.ReactNode;\n\n /** Function to serialize value into a string for formatting. Called with (value, null, 2) where 2 is the indentation level. @default JSON.stringify */\n serialize?: typeof JSON.stringify;\n\n /** Function to deserialize string value for formatting and validation. Must throw an error if the string is invalid JSON. @default JSON.parse */\n deserialize?: typeof JSON.parse;\n\n /** Number of spaces to use as white space for formatting. Passed as the third argument to `serialize` function. @default 2 */\n indentSpaces?: number;\n}\n\nexport type JsonInputFactory = Factory<{\n props: JsonInputProps;\n ref: HTMLTextAreaElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {\n serialize: JSON.stringify,\n deserialize: JSON.parse,\n indentSpaces: 2,\n} satisfies Partial<JsonInputProps>;\n\nexport const JsonInput = factory<JsonInputFactory>((props) => {\n const {\n value,\n defaultValue,\n onChange,\n formatOnBlur,\n validationError,\n serialize,\n deserialize,\n onFocus,\n onBlur,\n readOnly,\n error,\n indentSpaces,\n ...others\n } = useProps(['Input', 'InputWrapper', 'JsonInput'], defaultProps, props);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\n\n const [valid, setValid] = useState(validateJson(_value, deserialize));\n\n const handleFocus = (event: React.FocusEvent<HTMLTextAreaElement>) => {\n onFocus?.(event);\n setValid(true);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLTextAreaElement>) => {\n onBlur?.(event);\n const isValid = validateJson(event.currentTarget.value, deserialize);\n formatOnBlur &&\n !readOnly &&\n isValid &&\n event.currentTarget.value.trim() !== '' &&\n setValue(serialize(deserialize(event.currentTarget.value), null, indentSpaces));\n setValid(isValid);\n };\n\n return (\n <Textarea\n value={_value}\n onChange={(event) => setValue(event.currentTarget.value)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n readOnly={readOnly}\n {...others}\n autoComplete=\"off\"\n __staticSelector=\"JsonInput\"\n error={valid ? error : validationError || true}\n data-monospace\n />\n );\n});\n\nJsonInput.classes = InputBase.classes;\nJsonInput.displayName = '@mantine/core/JsonInput';\n\nexport namespace JsonInput {\n export type Props = JsonInputProps;\n export type Factory = JsonInputFactory;\n}\n"],"mappings":";;;;;;;;;;;AAwCA,MAAM,eAAe;CACnB,WAAW,KAAK;CAChB,aAAa,KAAK;CAClB,cAAc;CACf;AAED,MAAa,YAAYA,gBAAAA,SAA2B,UAAU;CAC5D,MAAM,EACJ,OACA,cACA,UACA,cACA,iBACA,WACA,aACA,SACA,QACA,UACA,OACA,cACA,GAAG,WACDC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;EAAY,EAAE,cAAc,MAAM;CAEzE,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAA4B;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqBC,sBAAAA,aAAa,QAAQ,YAAY,CAAC;CAErE,MAAM,eAAe,UAAiD;AACpE,YAAU,MAAM;AAChB,WAAS,KAAK;;CAGhB,MAAM,cAAc,UAAiD;AACnE,WAAS,MAAM;EACf,MAAM,UAAUA,sBAAAA,aAAa,MAAM,cAAc,OAAO,YAAY;AACpE,kBACE,CAAC,YACD,WACA,MAAM,cAAc,MAAM,MAAM,KAAK,MACrC,SAAS,UAAU,YAAY,MAAM,cAAc,MAAM,EAAE,MAAM,aAAa,CAAC;AACjF,WAAS,QAAQ;;AAGnB,QACE,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,UAAD;EACE,OAAO;EACP,WAAW,UAAU,SAAS,MAAM,cAAc,MAAM;EACxD,SAAS;EACT,QAAQ;EACE;EACV,GAAI;EACJ,cAAa;EACb,kBAAiB;EACjB,OAAO,QAAQ,QAAQ,mBAAmB;EAC1C,kBAAA;EACA,CAAA;EAEJ;AAEF,UAAU,UAAUC,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
@@ -8,7 +8,11 @@ let react_jsx_runtime = require("react/jsx-runtime");
8
8
  //#region packages/@mantine/core/src/components/MaskInput/MaskInput.tsx
9
9
  const defaultProps = {};
10
10
  const MaskInput = require_factory.factory((props) => {
11
- const { maskRef, elementProps } = require_use_mask_input_props.useMaskInputProps(require_use_props.useProps("MaskInput", defaultProps, props));
11
+ const { maskRef, elementProps } = require_use_mask_input_props.useMaskInputProps(require_use_props.useProps([
12
+ "Input",
13
+ "InputWrapper",
14
+ "MaskInput"
15
+ ], defaultProps, props));
12
16
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InputBase.InputBase, {
13
17
  component: "input",
14
18
  ref: maskRef,