@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.
- package/cjs/components/Autocomplete/Autocomplete.cjs +5 -1
- package/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/cjs/components/Checkbox/Checkbox.cjs +4 -1
- package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/cjs/components/ColorInput/ColorInput.cjs +5 -1
- package/cjs/components/ColorInput/ColorInput.cjs.map +1 -1
- package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs +17 -0
- package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs.map +1 -0
- package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs +170 -0
- package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs.map +1 -0
- package/cjs/components/FileInput/FileInput.cjs +5 -1
- package/cjs/components/FileInput/FileInput.cjs.map +1 -1
- package/cjs/components/Input/use-input-props.cjs +5 -1
- package/cjs/components/Input/use-input-props.cjs.map +1 -1
- package/cjs/components/JsonInput/JsonInput.cjs +5 -2
- package/cjs/components/JsonInput/JsonInput.cjs.map +1 -1
- package/cjs/components/MaskInput/MaskInput.cjs +5 -1
- package/cjs/components/MaskInput/MaskInput.cjs.map +1 -1
- package/cjs/components/MaskInput/use-mask-input-props.cjs +3 -2
- package/cjs/components/MaskInput/use-mask-input-props.cjs.map +1 -1
- package/cjs/components/MultiSelect/MultiSelect.cjs +19 -3
- package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/cjs/components/NativeSelect/NativeSelect.cjs +5 -1
- package/cjs/components/NativeSelect/NativeSelect.cjs.map +1 -1
- package/cjs/components/NumberInput/NumberInput.cjs +5 -1
- package/cjs/components/NumberInput/NumberInput.cjs.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs +5 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/cjs/components/Pill/Pill.module.cjs.map +1 -1
- package/cjs/components/PillsInput/PillsInput.cjs +5 -1
- package/cjs/components/PillsInput/PillsInput.cjs.map +1 -1
- package/cjs/components/PinInput/PinInput.cjs +1 -1
- package/cjs/components/PinInput/PinInput.cjs.map +1 -1
- package/cjs/components/RollingNumber/DigitColumn.cjs +46 -0
- package/cjs/components/RollingNumber/DigitColumn.cjs.map +1 -0
- package/cjs/components/RollingNumber/RollingNumber.cjs +102 -0
- package/cjs/components/RollingNumber/RollingNumber.cjs.map +1 -0
- package/cjs/components/RollingNumber/RollingNumber.module.cjs +13 -0
- package/cjs/components/RollingNumber/RollingNumber.module.cjs.map +1 -0
- package/cjs/components/RollingNumber/build-value.cjs +22 -0
- package/cjs/components/RollingNumber/build-value.cjs.map +1 -0
- package/cjs/components/RollingNumber/get-digit-parts.cjs +40 -0
- package/cjs/components/RollingNumber/get-digit-parts.cjs.map +1 -0
- package/cjs/components/RollingNumber/get-render-slots.cjs +78 -0
- package/cjs/components/RollingNumber/get-render-slots.cjs.map +1 -0
- package/cjs/components/Select/Select.cjs +5 -1
- package/cjs/components/Select/Select.cjs.map +1 -1
- package/cjs/components/TagsInput/TagsInput.cjs +19 -4
- package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
- package/cjs/components/TextInput/TextInput.cjs +5 -1
- package/cjs/components/TextInput/TextInput.cjs.map +1 -1
- package/cjs/components/Textarea/Textarea.cjs +5 -2
- package/cjs/components/Textarea/Textarea.cjs.map +1 -1
- package/cjs/components/Tree/is-node-checked/is-node-checked.cjs +1 -0
- package/cjs/components/Tree/is-node-indeterminate/is-node-indeterminate.cjs +1 -0
- package/cjs/components/TreeSelect/TreeSelect.cjs +601 -0
- package/cjs/components/TreeSelect/TreeSelect.cjs.map +1 -0
- package/cjs/components/TreeSelect/TreeSelect.module.cjs +16 -0
- package/cjs/components/TreeSelect/TreeSelect.module.cjs.map +1 -0
- package/cjs/components/TreeSelect/TreeSelectOption.cjs +95 -0
- package/cjs/components/TreeSelect/TreeSelectOption.cjs.map +1 -0
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs +34 -0
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs.map +1 -0
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs +30 -0
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs.map +1 -0
- package/cjs/core/MantineProvider/use-props/use-props.cjs +10 -2
- package/cjs/core/MantineProvider/use-props/use-props.cjs.map +1 -1
- package/cjs/index.cjs +8 -0
- package/esm/components/Autocomplete/Autocomplete.mjs +5 -1
- package/esm/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/esm/components/Checkbox/Checkbox.mjs +4 -1
- package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
- package/esm/components/ColorInput/ColorInput.mjs +5 -1
- package/esm/components/ColorInput/ColorInput.mjs.map +1 -1
- package/esm/components/Combobox/use-pills-reorder/move-pill.mjs +17 -0
- package/esm/components/Combobox/use-pills-reorder/move-pill.mjs.map +1 -0
- package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs +169 -0
- package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs.map +1 -0
- package/esm/components/FileInput/FileInput.mjs +5 -1
- package/esm/components/FileInput/FileInput.mjs.map +1 -1
- package/esm/components/Input/use-input-props.mjs +5 -1
- package/esm/components/Input/use-input-props.mjs.map +1 -1
- package/esm/components/JsonInput/JsonInput.mjs +5 -2
- package/esm/components/JsonInput/JsonInput.mjs.map +1 -1
- package/esm/components/MaskInput/MaskInput.mjs +5 -1
- package/esm/components/MaskInput/MaskInput.mjs.map +1 -1
- package/esm/components/MaskInput/use-mask-input-props.mjs +4 -3
- package/esm/components/MaskInput/use-mask-input-props.mjs.map +1 -1
- package/esm/components/MultiSelect/MultiSelect.mjs +19 -3
- package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
- package/esm/components/NativeSelect/NativeSelect.mjs +5 -1
- package/esm/components/NativeSelect/NativeSelect.mjs.map +1 -1
- package/esm/components/NumberInput/NumberInput.mjs +5 -1
- package/esm/components/NumberInput/NumberInput.mjs.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.mjs +5 -1
- package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
- package/esm/components/Pill/Pill.module.mjs.map +1 -1
- package/esm/components/PillsInput/PillsInput.mjs +5 -1
- package/esm/components/PillsInput/PillsInput.mjs.map +1 -1
- package/esm/components/PinInput/PinInput.mjs +1 -1
- package/esm/components/PinInput/PinInput.mjs.map +1 -1
- package/esm/components/RollingNumber/DigitColumn.mjs +45 -0
- package/esm/components/RollingNumber/DigitColumn.mjs.map +1 -0
- package/esm/components/RollingNumber/RollingNumber.mjs +101 -0
- package/esm/components/RollingNumber/RollingNumber.mjs.map +1 -0
- package/esm/components/RollingNumber/RollingNumber.module.mjs +13 -0
- package/esm/components/RollingNumber/RollingNumber.module.mjs.map +1 -0
- package/esm/components/RollingNumber/build-value.mjs +22 -0
- package/esm/components/RollingNumber/build-value.mjs.map +1 -0
- package/esm/components/RollingNumber/get-digit-parts.mjs +40 -0
- package/esm/components/RollingNumber/get-digit-parts.mjs.map +1 -0
- package/esm/components/RollingNumber/get-render-slots.mjs +78 -0
- package/esm/components/RollingNumber/get-render-slots.mjs.map +1 -0
- package/esm/components/Select/Select.mjs +5 -1
- package/esm/components/Select/Select.mjs.map +1 -1
- package/esm/components/TagsInput/TagsInput.mjs +19 -4
- package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
- package/esm/components/TextInput/TextInput.mjs +5 -1
- package/esm/components/TextInput/TextInput.mjs.map +1 -1
- package/esm/components/Textarea/Textarea.mjs +5 -2
- package/esm/components/Textarea/Textarea.mjs.map +1 -1
- package/esm/components/Tree/is-node-checked/is-node-checked.mjs +1 -1
- package/esm/components/Tree/is-node-indeterminate/is-node-indeterminate.mjs +1 -1
- package/esm/components/TreeSelect/TreeSelect.mjs +600 -0
- package/esm/components/TreeSelect/TreeSelect.mjs.map +1 -0
- package/esm/components/TreeSelect/TreeSelect.module.mjs +16 -0
- package/esm/components/TreeSelect/TreeSelect.module.mjs.map +1 -0
- package/esm/components/TreeSelect/TreeSelectOption.mjs +94 -0
- package/esm/components/TreeSelect/TreeSelectOption.mjs.map +1 -0
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs +34 -0
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs.map +1 -0
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs +29 -0
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs.map +1 -0
- package/esm/core/MantineProvider/use-props/use-props.mjs +10 -2
- package/esm/core/MantineProvider/use-props/use-props.mjs.map +1 -1
- package/esm/index.mjs +5 -1
- package/lib/components/Combobox/Combobox.types.d.ts +3 -0
- package/lib/components/Combobox/index.d.ts +2 -0
- package/lib/components/Combobox/use-pills-reorder/move-pill.d.ts +2 -0
- package/lib/components/Combobox/use-pills-reorder/use-pills-reorder.d.ts +26 -0
- package/lib/components/MaskInput/MaskInput.d.ts +2 -0
- package/lib/components/MultiSelect/MultiSelect.d.ts +2 -0
- package/lib/components/RollingNumber/DigitColumn.d.ts +11 -0
- package/lib/components/RollingNumber/RollingNumber.d.ts +41 -0
- package/lib/components/RollingNumber/build-value.d.ts +10 -0
- package/lib/components/RollingNumber/get-digit-parts.d.ts +12 -0
- package/lib/components/RollingNumber/get-render-slots.d.ts +35 -0
- package/lib/components/RollingNumber/index.d.ts +9 -0
- package/lib/components/TagsInput/TagsInput.d.ts +2 -0
- package/lib/components/TreeSelect/TreeSelect.d.ts +124 -0
- package/lib/components/TreeSelect/TreeSelectOption.d.ts +36 -0
- package/lib/components/TreeSelect/flatten-tree-select-data.d.ts +12 -0
- package/lib/components/TreeSelect/get-checked-values-by-strategy.d.ts +4 -0
- package/lib/components/TreeSelect/index.d.ts +13 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/core/MantineProvider/use-props/use-props.d.ts +1 -1
- package/package.json +2 -2
- package/styles/Pill.css +35 -0
- package/styles/Pill.layer.css +35 -0
- package/styles/RollingNumber.css +60 -0
- package/styles/RollingNumber.layer.css +61 -0
- package/styles/TreeSelect.css +113 -0
- package/styles/TreeSelect.layer.css +114 -0
- package/styles.css +210 -0
- package/styles.layer.css +210 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeSelect.cjs","names":["genericFactory","useProps","useCombobox","getTreeExpandedState","findTreeNode","expandToLeafChecked","filterTreeData","flattenTreeSelectData","useStyles","useResolvedStylesApi","extractStyleProps","isNodeChecked","getChildrenNodesValues","checkedToValue","Combobox","Pill","isNodeIndeterminate","TreeSelectOption","classes","ScrollArea","PillsInput","InputBase"],"sources":["../../../src/components/TreeSelect/TreeSelect.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n genericFactory,\n MantineColor,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Combobox, ComboboxLikeStylesNames, useCombobox } from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Pill } from '../Pill';\nimport { PillsInput } from '../PillsInput';\nimport { ScrollArea, ScrollAreaProps } from '../ScrollArea';\nimport type { TreeNodeData } from '../Tree';\nimport { filterTreeData } from '../Tree/filter-tree-data/filter-tree-data';\nimport {\n findTreeNode,\n getChildrenNodesValues,\n} from '../Tree/get-children-nodes-values/get-children-nodes-values';\nimport { isNodeChecked } from '../Tree/is-node-checked/is-node-checked';\nimport { isNodeIndeterminate } from '../Tree/is-node-indeterminate/is-node-indeterminate';\nimport { getTreeExpandedState, TreeExpandedState } from '../Tree/use-tree';\nimport { flattenTreeSelectData } from './flatten-tree-select-data';\nimport {\n CheckedStrategy,\n checkedToValue,\n expandToLeafChecked,\n} from './get-checked-values-by-strategy';\nimport {\n TreeSelectChevronAriaLabels,\n TreeSelectOption,\n TreeSelectRenderNodePayload,\n} from './TreeSelectOption';\nimport classes from './TreeSelect.module.css';\n\nexport type TreeSelectStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport type TreeSelectMode = 'single' | 'multiple' | 'checkbox';\n\nexport type TreeSelectValue<Mode extends TreeSelectMode> = Mode extends 'single'\n ? string | null\n : string[];\n\nexport interface TreeSelectProps<Mode extends TreeSelectMode = 'single'>\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<TreeSelectFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Tree data */\n data: TreeNodeData[];\n\n /** Selection mode: 'single', 'multiple', or 'checkbox' (with cascade) @default 'single' */\n mode?: Mode;\n\n /** Controlled value */\n value?: TreeSelectValue<Mode>;\n\n /** Default value */\n defaultValue?: TreeSelectValue<Mode>;\n\n /** Called when value changes */\n onChange?: (value: TreeSelectValue<Mode>) => void;\n\n /** Disables parent-child cascade in checkbox mode @default false */\n checkStrictly?: boolean;\n\n /** Controls which checked nodes appear in value/pills in checkbox mode @default 'child' */\n checkedStrategy?: CheckedStrategy;\n\n /** Default expanded node values */\n defaultExpandedValues?: string[];\n\n /** Expand all nodes by default @default false */\n defaultExpandAll?: boolean;\n\n /** Controlled expanded state */\n expandedValues?: string[];\n\n /** Called when expanded state changes */\n onExpandedChange?: (values: string[]) => void;\n\n /** Also toggle expand when clicking a parent node (not just the chevron). In `single` and `multiple` modes, parent clicks only expand; only leaves can be selected. In `checkbox` mode, parent clicks both check and expand. @default false */\n expandOnClick?: boolean;\n\n /** Enables search filtering @default false */\n searchable?: boolean;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Custom filter function */\n filter?: (query: string, node: TreeNodeData) => boolean;\n\n /** Message when no nodes match search */\n nothingFoundMessage?: React.ReactNode;\n\n /** Allows deselecting in single mode @default true */\n allowDeselect?: boolean;\n\n /** Shows clear button @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props for the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Maximum selectable values (multiple/checkbox mode) */\n maxValues?: number;\n\n /** Maximum displayed pills before \"+N more\" */\n maxDisplayedValues?: number;\n\n /** Content shown when values overflow maxDisplayedValues */\n maxDisplayedValuesContent?: React.ReactNode | ((overflow: number) => React.ReactNode);\n\n /** Called with removed value in multiple/checkbox mode */\n onRemove?: (value: string) => void;\n\n /** Called when clear button is clicked */\n onClear?: () => void;\n\n /** Custom node rendering in the dropdown */\n renderNode?: (payload: TreeSelectRenderNodePayload) => React.ReactNode;\n\n /** Show tree connection lines between parent and child nodes @default true */\n withLines?: boolean;\n\n /** Props for the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Divider for hidden input values @default ',' */\n hiddenInputValuesDivider?: string;\n\n /** Props for the ScrollArea in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls the default chevron color */\n chevronColor?: MantineColor;\n\n /** Max dropdown height @default 220 */\n maxDropdownHeight?: number | string;\n\n /** Controlled dropdown state */\n dropdownOpened?: boolean;\n\n /** Default dropdown state */\n defaultDropdownOpened?: boolean;\n\n /** Called when dropdown opens */\n onDropdownOpen?: () => void;\n\n /** Called when dropdown closes */\n onDropdownClose?: () => void;\n\n /** Props passed to the underlying Combobox */\n comboboxProps?: Record<string, any>;\n\n /** Clear search on selection change @default true */\n clearSearchOnChange?: boolean;\n\n /** Opens dropdown on focus (searchable mode) @default true */\n openOnFocus?: boolean;\n\n /** aria-label values for the expand/collapse chevron button */\n chevronAriaLabels?: TreeSelectChevronAriaLabels;\n}\n\nexport type TreeSelectFactory = Factory<{\n props: TreeSelectProps;\n ref: HTMLInputElement;\n stylesNames: TreeSelectStylesNames;\n variant: InputVariant;\n signature: <Mode extends TreeSelectMode = 'single'>(\n props: TreeSelectProps<Mode>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n mode: 'single',\n allowDeselect: true,\n checkedStrategy: 'child',\n maxValues: Infinity,\n hiddenInputValuesDivider: ',',\n clearSearchOnChange: true,\n openOnFocus: true,\n size: 'sm',\n withLines: true,\n} satisfies Partial<TreeSelectProps<TreeSelectMode>>;\n\nconst clearSectionOffset: Record<string, number> = {\n xs: 41,\n sm: 50,\n md: 60,\n lg: 72,\n xl: 89,\n};\n\nfunction getAncestorsToNode(value: string, nodes: TreeNodeData[]): string[] | null {\n for (const node of nodes) {\n if (node.value === value) {\n return [];\n }\n if (Array.isArray(node.children)) {\n const path = getAncestorsToNode(value, node.children);\n if (path !== null) {\n return [node.value, ...path];\n }\n }\n }\n return null;\n}\n\nexport const TreeSelect = genericFactory<TreeSelectFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'TreeSelect'], defaultProps as any, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n data,\n mode,\n value,\n defaultValue,\n onChange,\n checkStrictly,\n checkedStrategy,\n defaultExpandedValues,\n defaultExpandAll,\n expandedValues,\n onExpandedChange,\n expandOnClick,\n searchable,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n filter,\n nothingFoundMessage,\n allowDeselect,\n clearable,\n clearSectionMode,\n clearButtonProps,\n maxValues,\n maxDisplayedValues,\n maxDisplayedValuesContent,\n onRemove,\n onClear,\n renderNode,\n withLines,\n hiddenInputProps,\n hiddenInputValuesDivider,\n scrollAreaProps,\n chevronColor,\n maxDropdownHeight,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n comboboxProps,\n clearSearchOnChange,\n openOnFocus,\n chevronAriaLabels,\n variant,\n onKeyDown,\n onFocus,\n onBlur,\n onClick,\n readOnly,\n disabled,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n labelProps,\n descriptionProps,\n errorProps,\n wrapperProps,\n description,\n label,\n error,\n withErrorStyles,\n name,\n form,\n id,\n placeholder,\n required,\n mod,\n attributes,\n ...others\n } = props;\n\n const isMulti = mode === 'multiple' || mode === 'checkbox';\n const isCheckbox = mode === 'checkbox';\n const _id = useId(id);\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\n });\n\n const initialExpanded = useMemo(() => {\n if (defaultExpandAll) {\n return getTreeExpandedState(data, '*');\n }\n if (defaultExpandedValues) {\n return getTreeExpandedState(data, defaultExpandedValues);\n }\n return getTreeExpandedState(data, []);\n }, []);\n\n const expandedToRecord = useCallback(\n (values: string[] | undefined): TreeExpandedState | undefined => {\n if (!values) {\n return undefined;\n }\n return getTreeExpandedState(data, values);\n },\n [data]\n );\n\n const [_expandedState, setExpandedState] = useUncontrolled<TreeExpandedState>({\n value: expandedToRecord(expandedValues),\n defaultValue: initialExpanded,\n finalValue: {},\n onChange: (val) => {\n if (onExpandedChange) {\n onExpandedChange(\n Object.entries(val)\n .filter(([, v]) => v)\n .map(([k]) => k)\n );\n }\n },\n });\n\n const toggleExpand = useCallback(\n (nodeValue: string) => {\n setExpandedState({ ..._expandedState, [nodeValue]: !_expandedState[nodeValue] });\n },\n [_expandedState]\n );\n\n const initialSearchValue = useMemo(() => {\n if (mode !== 'single' || !defaultValue) {\n return '';\n }\n const node = findTreeNode(defaultValue as string, data);\n return node ? (typeof node.label === 'string' ? node.label : '') : '';\n }, []);\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: initialSearchValue,\n onChange: onSearchChange,\n });\n\n const handleSearchChange = (val: string) => {\n setSearchValue(val);\n combobox.resetSelectedOption();\n };\n\n const [_value, setValue] = useUncontrolled({\n value: value as any,\n defaultValue: defaultValue as any,\n finalValue: isMulti ? [] : null,\n onChange,\n });\n\n const internalChecked = useMemo(() => {\n if (!isCheckbox || !_value || !Array.isArray(_value)) {\n return [];\n }\n if (checkStrictly) {\n return _value;\n }\n return expandToLeafChecked(_value, data);\n }, [isCheckbox, _value, data, checkStrictly]);\n\n const filteredData = useMemo(() => {\n if (!searchable || !_searchValue) {\n return data;\n }\n if (mode === 'single' && _value) {\n const node = findTreeNode(_value as string, data);\n if (node && _searchValue === (typeof node.label === 'string' ? node.label : '')) {\n return data;\n }\n }\n return filterTreeData(data, _searchValue, filter);\n }, [data, _searchValue, filter, searchable, mode, _value]);\n\n const expandedForRender = useMemo(() => {\n if (_searchValue && filteredData !== data) {\n const expanded = { ..._expandedState };\n const expandFilteredParents = (nodes: TreeNodeData[]) => {\n for (const node of nodes) {\n if (Array.isArray(node.children) && node.children.length > 0) {\n expanded[node.value] = true;\n expandFilteredParents(node.children);\n }\n }\n };\n expandFilteredParents(filteredData);\n return expanded;\n }\n return _expandedState;\n }, [filteredData, _expandedState, _searchValue, data]);\n\n const flatNodes = useMemo(\n () => flattenTreeSelectData(filteredData, expandedForRender),\n [filteredData, expandedForRender]\n );\n\n const flatNodesRef = useRef(flatNodes);\n flatNodesRef.current = flatNodes;\n\n const nodeLookup = useMemo(() => {\n const lookup: Record<string, TreeNodeData> = {};\n const walk = (nodes: TreeNodeData[]) => {\n for (const node of nodes) {\n lookup[node.value] = node;\n if (Array.isArray(node.children)) {\n walk(node.children);\n }\n }\n };\n walk(data);\n return lookup;\n }, [data]);\n\n const getNodeLabel = (nodeValue: string): string => {\n const node = nodeLookup[nodeValue];\n if (!node) {\n return nodeValue;\n }\n return typeof node.label === 'string' ? node.label : nodeValue;\n };\n\n const getStyles = useStyles<TreeSelectFactory>({\n name: 'TreeSelect',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<TreeSelectFactory>({\n props,\n styles,\n classNames,\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const handleOptionSubmit = (val: string) => {\n if (mode === 'single') {\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n toggleExpand(val);\n return;\n }\n }\n const nextValue = allowDeselect && val === _value ? null : val;\n setValue(nextValue);\n combobox.closeDropdown();\n if (clearSearchOnChange) {\n handleSearchChange(nextValue ? getNodeLabel(nextValue) : '');\n }\n } else if (mode === 'multiple') {\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n toggleExpand(val);\n return;\n }\n }\n const arr = (_value as string[]) || [];\n if (arr.includes(val)) {\n setValue(arr.filter((v: string) => v !== val));\n onRemove?.(val);\n } else if (arr.length < (maxValues ?? Infinity)) {\n setValue([...arr, val]);\n } else {\n return;\n }\n if (clearSearchOnChange) {\n setSearchValue('');\n }\n } else if (mode === 'checkbox') {\n const nodeChecked = checkStrictly\n ? internalChecked.includes(val)\n : isNodeChecked(val, data, internalChecked);\n\n let newInternalChecked: string[];\n if (checkStrictly) {\n newInternalChecked = nodeChecked\n ? internalChecked.filter((v) => v !== val)\n : [...internalChecked, val];\n } else {\n const childLeaves = getChildrenNodesValues(val, data);\n if (nodeChecked) {\n newInternalChecked = internalChecked.filter((v) => !childLeaves.includes(v));\n } else {\n newInternalChecked = [...new Set([...internalChecked, ...childLeaves])];\n }\n }\n\n const newValue = checkedToValue(newInternalChecked, data, checkedStrategy!);\n if (!nodeChecked && newValue.length > (maxValues ?? Infinity)) {\n return;\n }\n setValue(newValue);\n if (clearSearchOnChange) {\n setSearchValue('');\n }\n\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n if (!_expandedState[val]) {\n toggleExpand(val);\n }\n }\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.key === ' ' && !searchable && isMulti) {\n event.preventDefault();\n combobox.toggleDropdown();\n }\n\n if (event.key === 'Backspace' && _searchValue.length === 0 && isMulti) {\n const arr = (_value as string[]) || [];\n if (arr.length > 0) {\n const removed = arr[arr.length - 1];\n onRemove?.(removed);\n setValue(arr.slice(0, -1));\n }\n }\n\n if (!combobox.dropdownOpened) {\n return;\n }\n\n const index = combobox.getSelectedOptionIndex();\n if (index < 0 || index >= flatNodesRef.current.length) {\n return;\n }\n\n const currentNode = flatNodesRef.current[index];\n\n if (event.key === 'ArrowRight') {\n if (currentNode.hasChildren && !currentNode.expanded) {\n event.preventDefault();\n toggleExpand(currentNode.node.value);\n }\n }\n\n if (event.key === 'ArrowLeft') {\n if (currentNode.hasChildren && currentNode.expanded) {\n event.preventDefault();\n toggleExpand(currentNode.node.value);\n } else if (currentNode.parent) {\n event.preventDefault();\n const parentIndex = flatNodesRef.current.findIndex(\n (n) => n.node.value === currentNode.parent\n );\n if (parentIndex >= 0) {\n combobox.selectOption(parentIndex);\n }\n }\n }\n };\n\n useEffect(() => {\n if (mode !== 'single' || !searchable) {\n return;\n }\n if (value === null) {\n handleSearchChange('');\n } else if (typeof value === 'string') {\n handleSearchChange(getNodeLabel(value));\n }\n }, [value]);\n\n const prevDropdownOpenedRef = useRef(false);\n useEffect(() => {\n if (combobox.dropdownOpened && !prevDropdownOpenedRef.current && searchable && _value) {\n const targets = Array.isArray(_value) ? _value : [_value];\n const newExpanded = { ..._expandedState };\n let changed = false;\n for (const target of targets) {\n const ancestors = getAncestorsToNode(target as string, data);\n if (ancestors) {\n for (const a of ancestors) {\n if (!newExpanded[a]) {\n newExpanded[a] = true;\n changed = true;\n }\n }\n }\n }\n if (changed) {\n setExpandedState(newExpanded);\n requestAnimationFrame(() => {\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n });\n }\n }\n prevDropdownOpenedRef.current = combobox.dropdownOpened;\n });\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n setValue(isMulti ? [] : null);\n handleSearchChange('');\n }}\n />\n );\n\n const hasValue = isMulti\n ? Array.isArray(_value) && _value.length > 0\n : _value != null && _value !== '';\n const _clearable = clearable && hasValue && !disabled && !readOnly;\n\n const singleDisplayLabel = useMemo(() => {\n if (mode !== 'single' || !_value) {\n return '';\n }\n return getNodeLabel(_value as string);\n }, [mode, _value, nodeLookup]);\n\n const displayValues = useMemo(() => {\n if (!isMulti || !Array.isArray(_value)) {\n return [];\n }\n return _value as string[];\n }, [isMulti, _value]);\n\n const pillsListStyle =\n _clearable && isMulti\n ? { paddingInlineEnd: clearSectionOffset[size as string] ?? clearSectionOffset.sm }\n : undefined;\n\n const visiblePills =\n maxDisplayedValues != null ? displayValues.slice(0, maxDisplayedValues) : displayValues;\n\n const overflowCount =\n maxDisplayedValues != null ? Math.max(0, displayValues.length - maxDisplayedValues) : 0;\n\n const pills = visiblePills.map((item, index) => (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly}\n onRemove={() => {\n if (isCheckbox) {\n const childLeaves = checkStrictly ? [item] : getChildrenNodesValues(item, data);\n const newInternal = internalChecked.filter((v) => !childLeaves.includes(v));\n setValue(checkedToValue(newInternal, data, checkedStrategy!));\n } else {\n setValue((_value as string[]).filter((v: string) => v !== item));\n }\n onRemove?.(item);\n }}\n unstyled={unstyled}\n disabled={disabled}\n {...getStyles('pill')}\n >\n {getNodeLabel(item)}\n </Pill>\n ));\n\n if (overflowCount > 0) {\n const overflowContent =\n typeof maxDisplayedValuesContent === 'function'\n ? maxDisplayedValuesContent(overflowCount)\n : maxDisplayedValuesContent || `+${overflowCount} more`;\n pills.push(\n <Pill key=\"__overflow\" unstyled={unstyled} disabled={disabled} {...getStyles('pill')}>\n {overflowContent}\n </Pill>\n );\n }\n\n const isEmpty = flatNodes.length === 0;\n\n const options = flatNodes.map((flatNode) => {\n const isSelected =\n mode === 'single'\n ? _value === flatNode.node.value\n : mode === 'multiple'\n ? ((_value as string[]) || []).includes(flatNode.node.value)\n : false;\n\n const nodeChecked = isCheckbox\n ? checkStrictly\n ? internalChecked.includes(flatNode.node.value)\n : isNodeChecked(flatNode.node.value, data, internalChecked)\n : false;\n\n const nodeIndeterminate =\n isCheckbox && !checkStrictly\n ? isNodeIndeterminate(flatNode.node.value, data, internalChecked)\n : false;\n\n return (\n <TreeSelectOption\n key={flatNode.node.value}\n node={flatNode.node}\n level={flatNode.level}\n expanded={flatNode.expanded}\n hasChildren={flatNode.hasChildren}\n selected={isSelected}\n checked={nodeChecked}\n indeterminate={nodeIndeterminate}\n showCheckbox={isCheckbox}\n isLastChild={flatNode.isLastChild}\n lineGuides={flatNode.lineGuides}\n withLines={!!withLines}\n onToggleExpand={toggleExpand}\n renderNode={renderNode}\n chevronAriaLabels={chevronAriaLabels}\n />\n );\n });\n\n const dropdown = (\n <Combobox.Dropdown hidden={readOnly || disabled}>\n <Combobox.Options\n className={classes.optionsWrapper}\n aria-multiselectable={isMulti || undefined}\n >\n <ScrollArea.Autosize\n mah={maxDropdownHeight ?? 220}\n type=\"scroll\"\n scrollbarSize=\"var(--combobox-padding)\"\n offsetScrollbars=\"y\"\n {...scrollAreaProps}\n >\n {options}\n </ScrollArea.Autosize>\n {isEmpty && nothingFoundMessage && <Combobox.Empty>{nothingFoundMessage}</Combobox.Empty>}\n </Combobox.Options>\n </Combobox.Dropdown>\n );\n\n if (isMulti) {\n return (\n <>\n <Combobox\n store={combobox}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n readOnly={readOnly}\n __staticSelector=\"TreeSelect\"\n attributes={attributes}\n onOptionSubmit={handleOptionSubmit}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"TreeSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n className={className}\n style={style}\n variant={variant}\n disabled={disabled}\n radius={radius}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n error={error}\n withErrorStyles={withErrorStyles}\n __stylesApiProps={{\n ...props,\n rightSectionPointerEvents: rightSectionPointerEvents || 'none',\n multiline: true,\n }}\n pointer={!searchable}\n onClick={() => (searchable ? combobox.openDropdown() : combobox.toggleDropdown())}\n data-expanded={combobox.dropdownOpened || undefined}\n id={_id}\n required={required}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group\n attributes={attributes}\n disabled={disabled}\n unstyled={unstyled}\n {...getStyles('pillsList', { style: pillsListStyle })}\n >\n {pills}\n <Combobox.EventsTarget autoComplete={autoComplete}>\n <PillsInput.Field\n {...rest}\n id={_id}\n placeholder={placeholder}\n type={!searchable && !placeholder ? 'hidden' : 'visible'}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onFocus={(event) => {\n onFocus?.(event);\n if (openOnFocus && searchable) {\n combobox.openDropdown();\n }\n }}\n onBlur={(event) => {\n onBlur?.(event);\n combobox.closeDropdown();\n handleSearchChange('');\n }}\n onKeyDown={handleKeyDown}\n value={_searchValue}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n if (searchable) {\n combobox.openDropdown();\n }\n }}\n disabled={disabled}\n readOnly={readOnly || !searchable}\n pointer={!searchable}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n name={name}\n valuesDivider={hiddenInputValuesDivider}\n value={_value}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n }\n\n return (\n <>\n <Combobox\n store={combobox}\n __staticSelector=\"TreeSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n onOptionSubmit={handleOptionSubmit}\n {...comboboxProps}\n >\n <Combobox.Target targetType={searchable ? 'input' : 'button'} autoComplete={autoComplete}>\n <InputBase\n id={_id}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n {...rest}\n {...styleProps}\n size={size}\n __staticSelector=\"TreeSelect\"\n disabled={disabled}\n readOnly={readOnly || !searchable}\n value={searchable ? _searchValue : singleDisplayLabel}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n combobox.openDropdown();\n }}\n onFocus={(event) => {\n if (openOnFocus && searchable) {\n combobox.openDropdown();\n }\n onFocus?.(event);\n }}\n onBlur={(event) => {\n if (searchable) {\n combobox.closeDropdown();\n }\n handleSearchChange(_value ? getNodeLabel(_value as string) : '');\n onBlur?.(event);\n }}\n onClick={(event) => {\n searchable ? combobox.openDropdown() : combobox.toggleDropdown();\n onClick?.(event);\n }}\n onKeyDown={handleKeyDown}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n pointer={!searchable}\n error={error}\n attributes={attributes}\n className={className}\n style={style}\n variant={variant}\n radius={radius}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n withErrorStyles={withErrorStyles}\n placeholder={placeholder}\n required={required}\n mod={mod}\n />\n </Combobox.Target>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n value={_value}\n name={name}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nTreeSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nTreeSelect.displayName = '@mantine/core/TreeSelect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4MA,MAAM,eAAe;CACnB,MAAM;CACN,eAAe;CACf,iBAAiB;CACjB,WAAW;CACX,0BAA0B;CAC1B,qBAAqB;CACrB,aAAa;CACb,MAAM;CACN,WAAW;CACZ;AAED,MAAM,qBAA6C;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AAED,SAAS,mBAAmB,OAAe,OAAwC;AACjF,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,KAAK,UAAU,MACjB,QAAO,EAAE;AAEX,MAAI,MAAM,QAAQ,KAAK,SAAS,EAAE;GAChC,MAAM,OAAO,mBAAmB,OAAO,KAAK,SAAS;AACrD,OAAI,SAAS,KACX,QAAO,CAAC,KAAK,OAAO,GAAG,KAAK;;;AAIlC,QAAO;;AAGT,MAAa,aAAaA,gBAAAA,gBAAmC,WAAW;CACtE,MAAM,QAAQC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;EAAa,EAAE,cAAqB,OAA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;IACH;IACK;IACD;IACJ;IACE;IACD;IACK;IACK;IACQ;IACR;IACC;IACA;IACH;IACG;IACL;IACF;IACM;IACN;IACE;IACD;IACN;IACU;IACJ;IACH;IACL;IACL,CAAA;GACc,CAAA,EACjB,SACQ;KACX,iBAAA,GAAA,kBAAA,KAACA,iBAAAA,SAAS,aAAV;EACE,OAAO;EACD;EACA;EACI;EACV,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,WAAW,UAAU;CAAE,GAAGO,kBAAAA,UAAU;CAAS,GAAGP,iBAAAA,SAAS;CAAS;AAClE,WAAW,cAAc"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/core/src/components/TreeSelect/TreeSelect.module.css
|
|
3
|
+
var TreeSelect_module_default = {
|
|
4
|
+
"optionsWrapper": "m_529d33e8",
|
|
5
|
+
"option": "m_28bb748",
|
|
6
|
+
"expandIcon": "m_aa3e3f86",
|
|
7
|
+
"checkIcon": "m_eaa4cdee",
|
|
8
|
+
"label": "m_ffe3a9c1",
|
|
9
|
+
"guideLine": "m_57207d5d",
|
|
10
|
+
"branchVertical": "m_41b9db0b",
|
|
11
|
+
"branchHorizontal": "m_1246e79"
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.default = TreeSelect_module_default;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=TreeSelect.module.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeSelect.module.cjs","names":[],"sources":["../../../src/components/TreeSelect/TreeSelect.module.css"],"sourcesContent":[".optionsWrapper {\n --ts-level-offset: 20px;\n --ts-line-width: rem(1px);\n --ts-line-color: var(--mantine-color-default-border);\n --ts-option-padding-y: 4px;\n --ts-option-padding-x: 8px;\n}\n\n.option {\n display: flex;\n align-items: center;\n gap: 6px;\n position: relative;\n padding: var(--ts-option-padding-y) var(--ts-option-padding-x);\n padding-inline-start: var(--ts-option-padding-x);\n}\n\n.expandIcon {\n display: flex;\n align-items: center;\n justify-content: center;\n --_ts-expand-icon-size: calc(1.45 * var(--combobox-option-fz, var(--mantine-font-size-sm)));\n width: var(--_ts-expand-icon-size);\n min-width: var(--_ts-expand-icon-size);\n height: var(--_ts-expand-icon-size);\n border-radius: var(--mantine-radius-sm);\n cursor: pointer;\n color: var(--mantine-color-dimmed);\n transform: rotate(-90deg);\n\n :where([data-combobox-selected]) & {\n color: var(--mantine-color-white);\n }\n\n @mixin where-rtl {\n transform: rotate(90deg);\n }\n\n &:where([data-expanded]) {\n transform: rotate(0deg);\n }\n\n @mixin hover {\n @mixin where-light {\n background-color: var(--mantine-color-gray-1);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-5);\n }\n }\n}\n\n.checkIcon {\n opacity: 0.4;\n width: 0.8em;\n min-width: 0.8em;\n height: 0.8em;\n margin-inline-start: auto;\n\n :where([data-combobox-selected]) & {\n opacity: 1;\n }\n}\n\n.label {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Tree lines */\n.guideLine {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 0;\n border-inline-start: var(--ts-line-width) solid var(--ts-line-color);\n pointer-events: none;\n}\n\n.branchVertical {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 0;\n border-inline-start: var(--ts-line-width) solid var(--ts-line-color);\n pointer-events: none;\n\n &:where([data-last]) {\n bottom: auto;\n height: 50%;\n }\n}\n\n.branchHorizontal {\n position: absolute;\n top: 50%;\n height: 0;\n border-top: var(--ts-line-width) solid var(--ts-line-color);\n pointer-events: none;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_AccordionChevron = require("../Accordion/AccordionChevron.cjs");
|
|
4
|
+
const require_Combobox = require("../Combobox/Combobox.cjs");
|
|
5
|
+
const require_CheckIcon = require("../Checkbox/CheckIcon.cjs");
|
|
6
|
+
const require_CheckboxIndicator = require("../Checkbox/CheckboxIndicator/CheckboxIndicator.cjs");
|
|
7
|
+
const require_TreeSelect_module = require("./TreeSelect.module.cjs");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
//#region packages/@mantine/core/src/components/TreeSelect/TreeSelectOption.tsx
|
|
10
|
+
const LEVEL_OFFSET = 20;
|
|
11
|
+
const BASE_PADDING = 8;
|
|
12
|
+
const LINE_CONTENT_GAP = 5;
|
|
13
|
+
const OPTION_GAP = 6;
|
|
14
|
+
function TreeSelectOption({ node, level, expanded, hasChildren, selected, checked, indeterminate, showCheckbox, isLastChild, lineGuides, withLines, onToggleExpand, renderNode, chevronAriaLabels }) {
|
|
15
|
+
const indentPx = (level - 1) * LEVEL_OFFSET;
|
|
16
|
+
const handleExpandClick = (event) => {
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
onToggleExpand(node.value);
|
|
20
|
+
};
|
|
21
|
+
const handleExpandMouseDown = (event) => {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
};
|
|
24
|
+
const customContent = renderNode ? renderNode({
|
|
25
|
+
node,
|
|
26
|
+
level,
|
|
27
|
+
expanded,
|
|
28
|
+
hasChildren,
|
|
29
|
+
selected,
|
|
30
|
+
checked,
|
|
31
|
+
indeterminate
|
|
32
|
+
}) : null;
|
|
33
|
+
const lineElements = withLines && level > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
34
|
+
lineGuides.map((show, g) => show ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
35
|
+
className: require_TreeSelect_module.default.guideLine,
|
|
36
|
+
style: { insetInlineStart: BASE_PADDING + (g + 1) * LEVEL_OFFSET - LEVEL_OFFSET / 2 }
|
|
37
|
+
}, `g${g}`) : null),
|
|
38
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
39
|
+
className: require_TreeSelect_module.default.branchVertical,
|
|
40
|
+
"data-last": isLastChild || void 0,
|
|
41
|
+
style: { insetInlineStart: BASE_PADDING + (level - 1) * LEVEL_OFFSET - LEVEL_OFFSET / 2 }
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
44
|
+
className: require_TreeSelect_module.default.branchHorizontal,
|
|
45
|
+
style: {
|
|
46
|
+
insetInlineStart: BASE_PADDING + (level - 1) * LEVEL_OFFSET - LEVEL_OFFSET / 2,
|
|
47
|
+
width: LEVEL_OFFSET / 2
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
] }) : null;
|
|
51
|
+
const isActive = selected || checked;
|
|
52
|
+
const showCheckMark = !showCheckbox && isActive;
|
|
53
|
+
const ariaChecked = showCheckbox ? indeterminate && !checked ? "mixed" : checked : void 0;
|
|
54
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Combobox.Combobox.Option, {
|
|
55
|
+
value: node.value,
|
|
56
|
+
disabled: node.nodeProps?.disabled,
|
|
57
|
+
active: isActive,
|
|
58
|
+
className: require_TreeSelect_module.default.option,
|
|
59
|
+
style: { paddingInlineStart: BASE_PADDING + indentPx + (withLines && level > 1 ? LINE_CONTENT_GAP : 0) + (!hasChildren ? OPTION_GAP : 0) },
|
|
60
|
+
"aria-selected": isActive,
|
|
61
|
+
"aria-level": level,
|
|
62
|
+
"aria-expanded": hasChildren ? expanded : void 0,
|
|
63
|
+
"aria-checked": ariaChecked,
|
|
64
|
+
children: [lineElements, customContent || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
65
|
+
hasChildren && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
66
|
+
className: require_TreeSelect_module.default.expandIcon,
|
|
67
|
+
"data-expanded": expanded || void 0,
|
|
68
|
+
onClick: handleExpandClick,
|
|
69
|
+
onKeyDown: (e) => {
|
|
70
|
+
if (e.key === "Enter") handleExpandClick(e);
|
|
71
|
+
},
|
|
72
|
+
onMouseDown: handleExpandMouseDown,
|
|
73
|
+
role: "button",
|
|
74
|
+
tabIndex: -1,
|
|
75
|
+
"aria-label": expanded ? chevronAriaLabels?.collapse ?? "Collapse" : chevronAriaLabels?.expand ?? "Expand",
|
|
76
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AccordionChevron.AccordionChevron, { size: "80%" })
|
|
77
|
+
}),
|
|
78
|
+
showCheckbox && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CheckboxIndicator.CheckboxIndicator, {
|
|
79
|
+
checked: checked || indeterminate,
|
|
80
|
+
indeterminate: !checked && indeterminate,
|
|
81
|
+
size: "18px"
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
84
|
+
className: require_TreeSelect_module.default.label,
|
|
85
|
+
children: node.label
|
|
86
|
+
}),
|
|
87
|
+
showCheckMark && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CheckIcon.CheckIcon, { className: require_TreeSelect_module.default.checkIcon })
|
|
88
|
+
] })]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
TreeSelectOption.displayName = "@mantine/core/TreeSelectOption";
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.TreeSelectOption = TreeSelectOption;
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=TreeSelectOption.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeSelectOption.cjs","names":["classes","Combobox","AccordionChevron","CheckboxIndicator","CheckIcon"],"sources":["../../../src/components/TreeSelect/TreeSelectOption.tsx"],"sourcesContent":["import { AccordionChevron } from '../Accordion';\nimport { CheckboxIndicator } from '../Checkbox/CheckboxIndicator/CheckboxIndicator';\nimport { CheckIcon } from '../Checkbox/CheckIcon';\nimport { Combobox } from '../Combobox';\nimport type { TreeNodeData } from '../Tree';\nimport classes from './TreeSelect.module.css';\n\nconst LEVEL_OFFSET = 20;\nconst BASE_PADDING = 8;\nconst LINE_CONTENT_GAP = 5;\nconst OPTION_GAP = 6;\n\nexport interface TreeSelectChevronAriaLabels {\n /** aria-label for the expand button when the node is collapsed @default 'Expand' */\n expand?: string;\n\n /** aria-label for the expand button when the node is expanded @default 'Collapse' */\n collapse?: string;\n}\n\nexport interface TreeSelectOptionProps {\n node: TreeNodeData;\n level: number;\n expanded: boolean;\n hasChildren: boolean;\n selected: boolean;\n checked: boolean;\n indeterminate: boolean;\n showCheckbox: boolean;\n isLastChild: boolean;\n lineGuides: boolean[];\n withLines: boolean;\n onToggleExpand: (value: string) => void;\n renderNode?: (payload: TreeSelectRenderNodePayload) => React.ReactNode;\n chevronAriaLabels?: TreeSelectChevronAriaLabels;\n}\n\nexport interface TreeSelectRenderNodePayload {\n node: TreeNodeData;\n level: number;\n expanded: boolean;\n hasChildren: boolean;\n selected: boolean;\n checked: boolean;\n indeterminate: boolean;\n}\n\nexport function TreeSelectOption({\n node,\n level,\n expanded,\n hasChildren,\n selected,\n checked,\n indeterminate,\n showCheckbox,\n isLastChild,\n lineGuides,\n withLines,\n onToggleExpand,\n renderNode,\n chevronAriaLabels,\n}: TreeSelectOptionProps) {\n const indentPx = (level - 1) * LEVEL_OFFSET;\n\n const handleExpandClick = (event: React.MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n onToggleExpand(node.value);\n };\n\n const handleExpandMouseDown = (event: React.MouseEvent) => {\n event.preventDefault();\n };\n\n const customContent = renderNode\n ? renderNode({ node, level, expanded, hasChildren, selected, checked, indeterminate })\n : null;\n\n const lineElements =\n withLines && level > 1 ? (\n <>\n {lineGuides.map((show, g) =>\n show ? (\n <span\n key={`g${g}`}\n className={classes.guideLine}\n style={{ insetInlineStart: BASE_PADDING + (g + 1) * LEVEL_OFFSET - LEVEL_OFFSET / 2 }}\n />\n ) : null\n )}\n <span\n className={classes.branchVertical}\n data-last={isLastChild || undefined}\n style={{\n insetInlineStart: BASE_PADDING + (level - 1) * LEVEL_OFFSET - LEVEL_OFFSET / 2,\n }}\n />\n <span\n className={classes.branchHorizontal}\n style={{\n insetInlineStart: BASE_PADDING + (level - 1) * LEVEL_OFFSET - LEVEL_OFFSET / 2,\n width: LEVEL_OFFSET / 2,\n }}\n />\n </>\n ) : null;\n\n const isActive = selected || checked;\n const showCheckMark = !showCheckbox && isActive;\n\n const ariaChecked = showCheckbox ? (indeterminate && !checked ? 'mixed' : checked) : undefined;\n\n return (\n <Combobox.Option\n value={node.value}\n disabled={node.nodeProps?.disabled}\n active={isActive}\n className={classes.option}\n style={{\n paddingInlineStart:\n BASE_PADDING +\n indentPx +\n (withLines && level > 1 ? LINE_CONTENT_GAP : 0) +\n (!hasChildren ? OPTION_GAP : 0),\n }}\n aria-selected={isActive}\n aria-level={level}\n aria-expanded={hasChildren ? expanded : undefined}\n aria-checked={ariaChecked}\n >\n {lineElements}\n {customContent || (\n <>\n {hasChildren && (\n <span\n className={classes.expandIcon}\n data-expanded={expanded || undefined}\n onClick={handleExpandClick}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleExpandClick(e as any);\n }\n }}\n onMouseDown={handleExpandMouseDown}\n role=\"button\"\n tabIndex={-1}\n aria-label={\n expanded\n ? (chevronAriaLabels?.collapse ?? 'Collapse')\n : (chevronAriaLabels?.expand ?? 'Expand')\n }\n >\n <AccordionChevron size=\"80%\" />\n </span>\n )}\n {showCheckbox && (\n <CheckboxIndicator\n checked={checked || indeterminate}\n indeterminate={!checked && indeterminate}\n size=\"18px\"\n />\n )}\n <span className={classes.label}>{node.label}</span>\n {showCheckMark && <CheckIcon className={classes.checkIcon} />}\n </>\n )}\n </Combobox.Option>\n );\n}\n\nTreeSelectOption.displayName = '@mantine/core/TreeSelectOption';\n"],"mappings":";;;;;;;;;AAOA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,mBAAmB;AACzB,MAAM,aAAa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EAC1B,QAAQ;EACR,WAAWD,0BAAAA,QAAQ;EACnB,OAAO,EACL,oBACE,eACA,YACC,aAAa,QAAQ,IAAI,mBAAmB,MAC5C,CAAC,cAAc,aAAa,IAChC;EACD,iBAAe;EACf,cAAY;EACZ,iBAAe,cAAc,WAAW,KAAA;EACxC,gBAAc;YAfhB,CAiBG,cACA,iBACC,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA;GACG,eACC,iBAAA,GAAA,kBAAA,KAAC,QAAD;IACE,WAAWA,0BAAAA,QAAQ;IACnB,iBAAe,YAAY,KAAA;IAC3B,SAAS;IACT,YAAY,MAAM;AAChB,SAAI,EAAE,QAAQ,QACZ,mBAAkB,EAAS;;IAG/B,aAAa;IACb,MAAK;IACL,UAAU;IACV,cACE,WACK,mBAAmB,YAAY,aAC/B,mBAAmB,UAAU;cAGpC,iBAAA,GAAA,kBAAA,KAACE,yBAAAA,kBAAD,EAAkB,MAAK,OAAQ,CAAA;IAC1B,CAAA;GAER,gBACC,iBAAA,GAAA,kBAAA,KAACC,0BAAAA,mBAAD;IACE,SAAS,WAAW;IACpB,eAAe,CAAC,WAAW;IAC3B,MAAK;IACL,CAAA;GAEJ,iBAAA,GAAA,kBAAA,KAAC,QAAD;IAAM,WAAWH,0BAAAA,QAAQ;cAAQ,KAAK;IAAa,CAAA;GAClD,iBAAiB,iBAAA,GAAA,kBAAA,KAACI,kBAAAA,WAAD,EAAW,WAAWJ,0BAAAA,QAAQ,WAAa,CAAA;GAC5D,EAAA,CAAA,CAEW;;;AAItB,iBAAiB,cAAc"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/core/src/components/TreeSelect/flatten-tree-select-data.ts
|
|
3
|
+
function flattenTo(acc, data, expandedState, parent, level, parentGuides) {
|
|
4
|
+
for (let i = 0; i < data.length; i++) {
|
|
5
|
+
const node = data[i];
|
|
6
|
+
const isLast = i === data.length - 1;
|
|
7
|
+
const hasLoadedChildren = Array.isArray(node.children);
|
|
8
|
+
const hasAsyncChildren = !!node.hasChildren && !hasLoadedChildren;
|
|
9
|
+
const hasChildren = hasLoadedChildren || hasAsyncChildren;
|
|
10
|
+
const expanded = expandedState[node.value] || false;
|
|
11
|
+
acc.push({
|
|
12
|
+
node,
|
|
13
|
+
level,
|
|
14
|
+
parent,
|
|
15
|
+
hasChildren,
|
|
16
|
+
expanded,
|
|
17
|
+
isLastChild: isLast,
|
|
18
|
+
lineGuides: parentGuides
|
|
19
|
+
});
|
|
20
|
+
if (expanded && hasLoadedChildren) {
|
|
21
|
+
const childGuides = level >= 2 ? [...parentGuides, !isLast] : [];
|
|
22
|
+
flattenTo(acc, node.children, expandedState, node.value, level + 1, childGuides);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function flattenTreeSelectData(data, expandedState) {
|
|
27
|
+
const result = [];
|
|
28
|
+
flattenTo(result, data, expandedState, null, 1, []);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.flattenTreeSelectData = flattenTreeSelectData;
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=flatten-tree-select-data.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten-tree-select-data.cjs","names":[],"sources":["../../../src/components/TreeSelect/flatten-tree-select-data.ts"],"sourcesContent":["import type { TreeNodeData } from '../Tree';\nimport type { TreeExpandedState } from '../Tree/use-tree';\n\nexport interface TreeSelectFlatNode {\n node: TreeNodeData;\n level: number;\n parent: string | null;\n hasChildren: boolean;\n expanded: boolean;\n isLastChild: boolean;\n lineGuides: boolean[];\n}\n\nfunction flattenTo(\n acc: TreeSelectFlatNode[],\n data: TreeNodeData[],\n expandedState: TreeExpandedState,\n parent: string | null,\n level: number,\n parentGuides: boolean[]\n): void {\n for (let i = 0; i < data.length; i++) {\n const node = data[i];\n const isLast = i === data.length - 1;\n const hasLoadedChildren = Array.isArray(node.children);\n const hasAsyncChildren = !!node.hasChildren && !hasLoadedChildren;\n const hasChildren = hasLoadedChildren || hasAsyncChildren;\n const expanded = expandedState[node.value] || false;\n\n acc.push({\n node,\n level,\n parent,\n hasChildren,\n expanded,\n isLastChild: isLast,\n lineGuides: parentGuides,\n });\n\n if (expanded && hasLoadedChildren) {\n const childGuides = level >= 2 ? [...parentGuides, !isLast] : [];\n flattenTo(acc, node.children!, expandedState, node.value, level + 1, childGuides);\n }\n }\n}\n\nexport function flattenTreeSelectData(\n data: TreeNodeData[],\n expandedState: TreeExpandedState\n): TreeSelectFlatNode[] {\n const result: TreeSelectFlatNode[] = [];\n flattenTo(result, data, expandedState, null, 1, []);\n return result;\n}\n"],"mappings":";;AAaA,SAAS,UACP,KACA,MACA,eACA,QACA,OACA,cACM;AACN,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,OAAO,KAAK;EAClB,MAAM,SAAS,MAAM,KAAK,SAAS;EACnC,MAAM,oBAAoB,MAAM,QAAQ,KAAK,SAAS;EACtD,MAAM,mBAAmB,CAAC,CAAC,KAAK,eAAe,CAAC;EAChD,MAAM,cAAc,qBAAqB;EACzC,MAAM,WAAW,cAAc,KAAK,UAAU;AAE9C,MAAI,KAAK;GACP;GACA;GACA;GACA;GACA;GACA,aAAa;GACb,YAAY;GACb,CAAC;AAEF,MAAI,YAAY,mBAAmB;GACjC,MAAM,cAAc,SAAS,IAAI,CAAC,GAAG,cAAc,CAAC,OAAO,GAAG,EAAE;AAChE,aAAU,KAAK,KAAK,UAAW,eAAe,KAAK,OAAO,QAAQ,GAAG,YAAY;;;;AAKvF,SAAgB,sBACd,MACA,eACsB;CACtB,MAAM,SAA+B,EAAE;AACvC,WAAU,QAAQ,MAAM,eAAe,MAAM,GAAG,EAAE,CAAC;AACnD,QAAO"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_get_children_nodes_values = require("../Tree/get-children-nodes-values/get-children-nodes-values.cjs");
|
|
3
|
+
const require_get_all_checked_nodes = require("../Tree/get-all-checked-nodes/get-all-checked-nodes.cjs");
|
|
4
|
+
const require_is_node_checked = require("../Tree/is-node-checked/is-node-checked.cjs");
|
|
5
|
+
//#region packages/@mantine/core/src/components/TreeSelect/get-checked-values-by-strategy.ts
|
|
6
|
+
function expandToLeafChecked(value, data) {
|
|
7
|
+
const leaves = /* @__PURE__ */ new Set();
|
|
8
|
+
for (const v of value) for (const leaf of require_get_children_nodes_values.getChildrenNodesValues(v, data)) leaves.add(leaf);
|
|
9
|
+
return Array.from(leaves);
|
|
10
|
+
}
|
|
11
|
+
function getTopmostCheckedParents(data, checkedState) {
|
|
12
|
+
const result = [];
|
|
13
|
+
for (const node of data) if (require_is_node_checked.isNodeChecked(node.value, data, checkedState)) result.push(node.value);
|
|
14
|
+
else if (Array.isArray(node.children) && node.children.length > 0) result.push(...getTopmostCheckedParents(node.children, checkedState));
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function checkedToValue(checkedState, data, strategy) {
|
|
18
|
+
if (checkedState.length === 0) return [];
|
|
19
|
+
switch (strategy) {
|
|
20
|
+
case "child": return checkedState;
|
|
21
|
+
case "all": return require_get_all_checked_nodes.getAllCheckedNodes(data, checkedState).result.filter((n) => n.checked).map((n) => n.value);
|
|
22
|
+
case "parent": return getTopmostCheckedParents(data, checkedState);
|
|
23
|
+
default: return checkedState;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.checkedToValue = checkedToValue;
|
|
28
|
+
exports.expandToLeafChecked = expandToLeafChecked;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=get-checked-values-by-strategy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-checked-values-by-strategy.cjs","names":["getChildrenNodesValues","isNodeChecked","getAllCheckedNodes"],"sources":["../../../src/components/TreeSelect/get-checked-values-by-strategy.ts"],"sourcesContent":["import type { TreeNodeData } from '../Tree';\nimport { getAllCheckedNodes } from '../Tree/get-all-checked-nodes/get-all-checked-nodes';\nimport { getChildrenNodesValues } from '../Tree/get-children-nodes-values/get-children-nodes-values';\nimport { isNodeChecked } from '../Tree/is-node-checked/is-node-checked';\n\nexport type CheckedStrategy = 'all' | 'parent' | 'child';\n\nexport function expandToLeafChecked(value: string[], data: TreeNodeData[]): string[] {\n const leaves = new Set<string>();\n for (const v of value) {\n for (const leaf of getChildrenNodesValues(v, data)) {\n leaves.add(leaf);\n }\n }\n return Array.from(leaves);\n}\n\nfunction getTopmostCheckedParents(data: TreeNodeData[], checkedState: string[]): string[] {\n const result: string[] = [];\n for (const node of data) {\n if (isNodeChecked(node.value, data, checkedState)) {\n result.push(node.value);\n } else if (Array.isArray(node.children) && node.children.length > 0) {\n result.push(...getTopmostCheckedParents(node.children, checkedState));\n }\n }\n return result;\n}\n\nexport function checkedToValue(\n checkedState: string[],\n data: TreeNodeData[],\n strategy: CheckedStrategy\n): string[] {\n if (checkedState.length === 0) {\n return [];\n }\n\n switch (strategy) {\n case 'child':\n return checkedState;\n case 'all':\n return getAllCheckedNodes(data, checkedState)\n .result.filter((n) => n.checked)\n .map((n) => n.value);\n case 'parent':\n return getTopmostCheckedParents(data, checkedState);\n default:\n return checkedState;\n }\n}\n"],"mappings":";;;;;AAOA,SAAgB,oBAAoB,OAAiB,MAAgC;CACnF,MAAM,yBAAS,IAAI,KAAa;AAChC,MAAK,MAAM,KAAK,MACd,MAAK,MAAM,QAAQA,kCAAAA,uBAAuB,GAAG,KAAK,CAChD,QAAO,IAAI,KAAK;AAGpB,QAAO,MAAM,KAAK,OAAO;;AAG3B,SAAS,yBAAyB,MAAsB,cAAkC;CACxF,MAAM,SAAmB,EAAE;AAC3B,MAAK,MAAM,QAAQ,KACjB,KAAIC,wBAAAA,cAAc,KAAK,OAAO,MAAM,aAAa,CAC/C,QAAO,KAAK,KAAK,MAAM;UACd,MAAM,QAAQ,KAAK,SAAS,IAAI,KAAK,SAAS,SAAS,EAChE,QAAO,KAAK,GAAG,yBAAyB,KAAK,UAAU,aAAa,CAAC;AAGzE,QAAO;;AAGT,SAAgB,eACd,cACA,MACA,UACU;AACV,KAAI,aAAa,WAAW,EAC1B,QAAO,EAAE;AAGX,SAAQ,UAAR;EACE,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAOC,8BAAAA,mBAAmB,MAAM,aAAa,CAC1C,OAAO,QAAQ,MAAM,EAAE,QAAQ,CAC/B,KAAK,MAAM,EAAE,MAAM;EACxB,KAAK,SACH,QAAO,yBAAyB,MAAM,aAAa;EACrD,QACE,QAAO"}
|
|
@@ -4,8 +4,16 @@ const require_MantineThemeProvider = require("../MantineThemeProvider/MantineThe
|
|
|
4
4
|
//#region packages/@mantine/core/src/core/MantineProvider/use-props/use-props.ts
|
|
5
5
|
function useProps(component, defaultProps, props) {
|
|
6
6
|
const theme = require_MantineThemeProvider.useMantineTheme();
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const names = (Array.isArray(component) ? component : [component]).filter(Boolean);
|
|
8
|
+
let contextProps = {};
|
|
9
|
+
for (const name of names) {
|
|
10
|
+
const payload = theme.components[name]?.defaultProps;
|
|
11
|
+
const resolved = typeof payload === "function" ? payload(theme) : payload;
|
|
12
|
+
if (resolved) contextProps = {
|
|
13
|
+
...contextProps,
|
|
14
|
+
...resolved
|
|
15
|
+
};
|
|
16
|
+
}
|
|
9
17
|
return {
|
|
10
18
|
...defaultProps,
|
|
11
19
|
...contextProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-props.cjs","names":["useMantineTheme","filterProps"],"sources":["../../../../src/core/MantineProvider/use-props/use-props.ts"],"sourcesContent":["import { filterProps } from '../../utils';\nimport { useMantineTheme } from '../MantineThemeProvider';\n\nexport function useProps<T extends Record<string, any>, U extends Partial<T> | null = {}>(\n component: string,\n defaultProps: U,\n props: T\n): T &\n (U extends null | undefined\n ? {}\n : {\n [Key in Extract<keyof T, keyof U>]-?: U[Key] | NonNullable<T[Key]>;\n }) {\n const theme = useMantineTheme();\n const
|
|
1
|
+
{"version":3,"file":"use-props.cjs","names":["useMantineTheme","filterProps"],"sources":["../../../../src/core/MantineProvider/use-props/use-props.ts"],"sourcesContent":["import { filterProps } from '../../utils';\nimport { useMantineTheme } from '../MantineThemeProvider';\n\nexport function useProps<T extends Record<string, any>, U extends Partial<T> | null = {}>(\n component: string | (string | undefined)[],\n defaultProps: U,\n props: T\n): T &\n (U extends null | undefined\n ? {}\n : {\n [Key in Extract<keyof T, keyof U>]-?: U[Key] | NonNullable<T[Key]>;\n }) {\n const theme = useMantineTheme();\n const names = (Array.isArray(component) ? component : [component]).filter(Boolean) as string[];\n\n let contextProps: Record<string, any> = {};\n for (const name of names) {\n const payload = theme.components[name]?.defaultProps;\n const resolved = typeof payload === 'function' ? payload(theme) : payload;\n if (resolved) {\n contextProps = { ...contextProps, ...resolved };\n }\n }\n\n return { ...defaultProps, ...contextProps, ...filterProps(props) } as any;\n}\n"],"mappings":";;;;AAGA,SAAgB,SACd,WACA,cACA,OAMO;CACP,MAAM,QAAQA,6BAAAA,iBAAiB;CAC/B,MAAM,SAAS,MAAM,QAAQ,UAAU,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,QAAQ;CAElF,IAAI,eAAoC,EAAE;AAC1C,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,UAAU,MAAM,WAAW,OAAO;EACxC,MAAM,WAAW,OAAO,YAAY,aAAa,QAAQ,MAAM,GAAG;AAClE,MAAI,SACF,gBAAe;GAAE,GAAG;GAAc,GAAG;GAAU;;AAInD,QAAO;EAAE,GAAG;EAAc,GAAG;EAAc,GAAGC,qBAAAA,YAAY,MAAM;EAAE"}
|
package/cjs/index.cjs
CHANGED
|
@@ -182,6 +182,7 @@ const require_is_options_group = require("./components/Combobox/OptionsDropdown/
|
|
|
182
182
|
const require_default_options_filter = require("./components/Combobox/OptionsDropdown/default-options-filter.cjs");
|
|
183
183
|
const require_OptionsDropdown = require("./components/Combobox/OptionsDropdown/OptionsDropdown.cjs");
|
|
184
184
|
const require_use_virtualized_combobox = require("./components/Combobox/use-combobox/use-virtualized-combobox.cjs");
|
|
185
|
+
const require_use_pills_reorder = require("./components/Combobox/use-pills-reorder/use-pills-reorder.cjs");
|
|
185
186
|
const require_Autocomplete = require("./components/Autocomplete/Autocomplete.cjs");
|
|
186
187
|
const require_AvatarGroup = require("./components/Avatar/AvatarGroup/AvatarGroup.cjs");
|
|
187
188
|
const require_Avatar = require("./components/Avatar/Avatar.cjs");
|
|
@@ -299,6 +300,7 @@ const require_RadioIcon = require("./components/Radio/RadioIcon.cjs");
|
|
|
299
300
|
const require_RadioIndicator = require("./components/Radio/RadioIndicator/RadioIndicator.cjs");
|
|
300
301
|
const require_Radio = require("./components/Radio/Radio.cjs");
|
|
301
302
|
const require_Rating = require("./components/Rating/Rating.cjs");
|
|
303
|
+
const require_RollingNumber = require("./components/RollingNumber/RollingNumber.cjs");
|
|
302
304
|
const require_TooltipFloating = require("./components/Tooltip/TooltipFloating/TooltipFloating.cjs");
|
|
303
305
|
const require_TooltipGroup = require("./components/Tooltip/TooltipGroup/TooltipGroup.cjs");
|
|
304
306
|
const require_Tooltip = require("./components/Tooltip/Tooltip.cjs");
|
|
@@ -343,6 +345,8 @@ const require_move_tree_node = require("./components/Tree/move-tree-node/move-tr
|
|
|
343
345
|
const require_filter_tree_data = require("./components/Tree/filter-tree-data/filter-tree-data.cjs");
|
|
344
346
|
const require_flatten_tree_data = require("./components/Tree/flatten-tree-data/flatten-tree-data.cjs");
|
|
345
347
|
const require_FlatTreeNode = require("./components/Tree/FlatTreeNode.cjs");
|
|
348
|
+
const require_TreeSelectOption = require("./components/TreeSelect/TreeSelectOption.cjs");
|
|
349
|
+
const require_TreeSelect = require("./components/TreeSelect/TreeSelect.cjs");
|
|
346
350
|
const require_Typography = require("./components/Typography/Typography.cjs");
|
|
347
351
|
let react_remove_scroll = require("react-remove-scroll");
|
|
348
352
|
exports.Accordion = require_Accordion.Accordion;
|
|
@@ -561,6 +565,7 @@ Object.defineProperty(exports, "RemoveScroll", {
|
|
|
561
565
|
}
|
|
562
566
|
});
|
|
563
567
|
exports.RingProgress = require_RingProgress.RingProgress;
|
|
568
|
+
exports.RollingNumber = require_RollingNumber.RollingNumber;
|
|
564
569
|
exports.STYlE_PROPS_DATA = require_style_props_data.STYlE_PROPS_DATA;
|
|
565
570
|
exports.ScrollArea = require_ScrollArea.ScrollArea;
|
|
566
571
|
exports.ScrollAreaAutosize = require_ScrollArea.ScrollAreaAutosize;
|
|
@@ -608,6 +613,8 @@ exports.TooltipGroup = require_TooltipGroup.TooltipGroup;
|
|
|
608
613
|
exports.TooltipGroupContext = require_TooltipGroup.TooltipGroupContext;
|
|
609
614
|
exports.Transition = require_Transition.Transition;
|
|
610
615
|
exports.Tree = require_Tree.Tree;
|
|
616
|
+
exports.TreeSelect = require_TreeSelect.TreeSelect;
|
|
617
|
+
exports.TreeSelectOption = require_TreeSelectOption.TreeSelectOption;
|
|
611
618
|
exports.Typography = require_Typography.Typography;
|
|
612
619
|
exports.UnstyledButton = require_UnstyledButton.UnstyledButton;
|
|
613
620
|
exports.VisuallyHidden = require_VisuallyHidden.VisuallyHidden;
|
|
@@ -736,6 +743,7 @@ exports.useMenuContext = require_Menu_context.useMenuContext;
|
|
|
736
743
|
exports.useModalContext = require_Modal_context.useModalContext;
|
|
737
744
|
exports.useModalsStack = require_use_modals_stack.useModalsStack;
|
|
738
745
|
exports.usePaginationContext = require_Pagination_context.usePaginationContext;
|
|
746
|
+
exports.usePillsReorder = require_use_pills_reorder.usePillsReorder;
|
|
739
747
|
exports.usePopoverContext = require_Popover_context.usePopoverContext;
|
|
740
748
|
exports.useProgressContext = require_Progress_context.useProgressContext;
|
|
741
749
|
exports.useProps = require_use_props.useProps;
|
|
@@ -13,7 +13,11 @@ import { useId as useId$1, useUncontrolled } from "@mantine/hooks";
|
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
//#region packages/@mantine/core/src/components/Autocomplete/Autocomplete.tsx
|
|
15
15
|
const Autocomplete = factory((_props) => {
|
|
16
|
-
const props = useProps(
|
|
16
|
+
const props = useProps([
|
|
17
|
+
"Input",
|
|
18
|
+
"InputWrapper",
|
|
19
|
+
"Autocomplete"
|
|
20
|
+
], { size: "sm" }, _props);
|
|
17
21
|
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;
|
|
18
22
|
const _id = useId$1(id);
|
|
19
23
|
const parsedData = getParsedComboboxData(data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.mjs","names":["useId"],"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,eAAe,SAA8B,WAAW;CACnE,MAAM,QAAQ,SACZ,
|
|
1
|
+
{"version":3,"file":"Autocomplete.mjs","names":["useId"],"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":";;;;;;;;;;;;;;AA4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AS,eAAe;;EAE1B,GAAI;YAfN,CAiBE,oBAAC,SAAS,QAAV;GAA+B;GAAc,uBAAA;aAC3C,oBAAC,WAAD;IACE,GAAI;IACE;IACN,kBAAiB;IACjB,gBAAgB;IAChB,aAAa,aAAa,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;IACpD,oBAAoB;IACN;IACJ;IACA;IACV,OAAO;IACA;IACP,WAAW,UAAU;AACnB,uBAAkB,MAAM,cAAc,MAAM;AAC5C,cAAS,cAAc;AACvB,kCAA6B,SAAS,mBAAmB;;IAE3D,UAAU,UAAU;AAClB,oBAAe,SAAS,cAAc;AACtC,eAAU,MAAM;;IAElB,SAAS,UAAU;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,oBAAC,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,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS;AACpE,aAAa,cAAc"}
|
|
@@ -110,7 +110,10 @@ const Checkbox = factory((_props) => {
|
|
|
110
110
|
component: "input",
|
|
111
111
|
id: uuid,
|
|
112
112
|
ref: useMergedRef(inputRef, ref),
|
|
113
|
-
mod: {
|
|
113
|
+
mod: {
|
|
114
|
+
error: !!error,
|
|
115
|
+
"with-error-styles": withErrorStyles
|
|
116
|
+
},
|
|
114
117
|
...getStyles("input", {
|
|
115
118
|
focusable: true,
|
|
116
119
|
variant
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.mjs","names":["useId","classes"],"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,MAAM;CACN,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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,MAAM;CACN,iBAAiB;CACjB,SAAS;CACT,QAAQ;CACT;AA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-size": getSize(size, "ci-preview-size") }
|
|
41
41
|
}));
|
|
42
42
|
const ColorInput = factory((_props) => {
|
|
43
|
-
const props = useProps(
|
|
43
|
+
const props = useProps([
|
|
44
|
+
"Input",
|
|
45
|
+
"InputWrapper",
|
|
46
|
+
"ColorInput"
|
|
47
|
+
], defaultProps, _props);
|
|
44
48
|
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 } = useInputProps("ColorInput", defaultProps, _props);
|
|
45
49
|
const getStyles = useStyles({
|
|
46
50
|
name: "ColorInput",
|