@mantine/core 7.0.0-beta.6 → 7.0.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.js +9 -4
- package/cjs/components/Autocomplete/Autocomplete.js.map +1 -1
- package/cjs/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.js +18 -2
- package/cjs/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.js.map +1 -1
- package/cjs/components/Combobox/ComboboxOptions/ComboboxOptions.js +2 -1
- package/cjs/components/Combobox/ComboboxOptions/ComboboxOptions.js.map +1 -1
- package/cjs/components/Combobox/ComboboxSearch/ComboboxSearch.js +1 -0
- package/cjs/components/Combobox/ComboboxSearch/ComboboxSearch.js.map +1 -1
- package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.js +18 -2
- package/cjs/components/Combobox/ComboboxTarget/ComboboxTarget.js.map +1 -1
- package/cjs/components/Combobox/OptionsDropdown/OptionsDropdown.js +5 -3
- package/cjs/components/Combobox/OptionsDropdown/OptionsDropdown.js.map +1 -1
- package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.js +2 -1
- package/cjs/components/Combobox/use-combobox-target-props/use-combobox-target-props.js.map +1 -1
- package/cjs/components/Grid/GridCol/GridColVariables.js +2 -1
- package/cjs/components/Grid/GridCol/GridColVariables.js.map +1 -1
- package/cjs/components/MultiSelect/MultiSelect.js +11 -5
- package/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.js +6 -1
- package/cjs/components/PasswordInput/PasswordInput.js.map +1 -1
- package/cjs/components/Select/Select.js +8 -3
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/SimpleGrid/SimpleGrid.js +1 -2
- package/cjs/components/SimpleGrid/SimpleGrid.js.map +1 -1
- package/cjs/components/SimpleGrid/SimpleGridVariables.js +4 -3
- package/cjs/components/SimpleGrid/SimpleGridVariables.js.map +1 -1
- package/cjs/components/Spoiler/Spoiler.js +4 -2
- package/cjs/components/Spoiler/Spoiler.js.map +1 -1
- package/cjs/components/TagsInput/TagsInput.js +11 -5
- package/cjs/components/TagsInput/TagsInput.js.map +1 -1
- package/cjs/index.css +28 -7
- package/esm/components/Autocomplete/Autocomplete.js +10 -5
- package/esm/components/Autocomplete/Autocomplete.js.map +1 -1
- package/esm/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.js +18 -2
- package/esm/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.js.map +1 -1
- package/esm/components/Combobox/ComboboxOptions/ComboboxOptions.js +2 -1
- package/esm/components/Combobox/ComboboxOptions/ComboboxOptions.js.map +1 -1
- package/esm/components/Combobox/ComboboxSearch/ComboboxSearch.js +1 -0
- package/esm/components/Combobox/ComboboxSearch/ComboboxSearch.js.map +1 -1
- package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.js +18 -2
- package/esm/components/Combobox/ComboboxTarget/ComboboxTarget.js.map +1 -1
- package/esm/components/Combobox/OptionsDropdown/OptionsDropdown.js +5 -3
- package/esm/components/Combobox/OptionsDropdown/OptionsDropdown.js.map +1 -1
- package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.js +2 -1
- package/esm/components/Combobox/use-combobox-target-props/use-combobox-target-props.js.map +1 -1
- package/esm/components/Grid/GridCol/GridColVariables.js +2 -1
- package/esm/components/Grid/GridCol/GridColVariables.js.map +1 -1
- package/esm/components/MultiSelect/MultiSelect.js +12 -6
- package/esm/components/MultiSelect/MultiSelect.js.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.js +6 -1
- package/esm/components/PasswordInput/PasswordInput.js.map +1 -1
- package/esm/components/Select/Select.js +9 -4
- package/esm/components/Select/Select.js.map +1 -1
- package/esm/components/SimpleGrid/SimpleGrid.js +1 -2
- package/esm/components/SimpleGrid/SimpleGrid.js.map +1 -1
- package/esm/components/SimpleGrid/SimpleGridVariables.js +4 -3
- package/esm/components/SimpleGrid/SimpleGridVariables.js.map +1 -1
- package/esm/components/Spoiler/Spoiler.js +4 -2
- package/esm/components/Spoiler/Spoiler.js.map +1 -1
- package/esm/components/TagsInput/TagsInput.js +12 -6
- package/esm/components/TagsInput/TagsInput.js.map +1 -1
- package/esm/index.css +28 -7
- package/esm/styles/Accordion.css +1 -1
- package/esm/styles/ActionIcon.css +1 -1
- package/esm/styles/Alert.css +1 -1
- package/esm/styles/Button.css +1 -1
- package/esm/styles/PasswordInput.css +1 -1
- package/lib/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.d.ts +2 -0
- package/lib/components/Combobox/ComboboxOptions/ComboboxOptions.d.ts +2 -0
- package/lib/components/Combobox/ComboboxTarget/ComboboxTarget.d.ts +2 -0
- package/lib/components/Combobox/OptionsDropdown/OptionsDropdown.d.ts +2 -1
- package/lib/components/Combobox/use-combobox-target-props/use-combobox-target-props.d.ts +3 -2
- package/package.json +2 -2
- package/esm/styles/Toggle.css +0 -1
|
@@ -77,7 +77,8 @@ const Autocomplete = factory.factory((_props, ref) => {
|
|
|
77
77
|
limit,
|
|
78
78
|
withScrollArea,
|
|
79
79
|
maxDropdownHeight,
|
|
80
|
-
size
|
|
80
|
+
size,
|
|
81
|
+
id
|
|
81
82
|
} = _a, others = __objRest(_a, [
|
|
82
83
|
"classNames",
|
|
83
84
|
"styles",
|
|
@@ -103,8 +104,10 @@ const Autocomplete = factory.factory((_props, ref) => {
|
|
|
103
104
|
"limit",
|
|
104
105
|
"withScrollArea",
|
|
105
106
|
"maxDropdownHeight",
|
|
106
|
-
"size"
|
|
107
|
+
"size",
|
|
108
|
+
"id"
|
|
107
109
|
]);
|
|
110
|
+
const _id = hooks.useId(id);
|
|
108
111
|
const parsedData = getParsedComboboxData.getParsedComboboxData(data);
|
|
109
112
|
const optionsLockup = getOptionsLockup.getOptionsLockup(parsedData);
|
|
110
113
|
const [_value, setValue] = hooks.useUncontrolled({
|
|
@@ -177,7 +180,8 @@ const Autocomplete = factory.factory((_props, ref) => {
|
|
|
177
180
|
},
|
|
178
181
|
classNames: resolvedClassNames,
|
|
179
182
|
styles: resolvedStyles,
|
|
180
|
-
unstyled
|
|
183
|
+
unstyled,
|
|
184
|
+
id: _id
|
|
181
185
|
})
|
|
182
186
|
)),
|
|
183
187
|
/* @__PURE__ */ React__default.createElement(
|
|
@@ -191,7 +195,8 @@ const Autocomplete = factory.factory((_props, ref) => {
|
|
|
191
195
|
hiddenWhenEmpty: true,
|
|
192
196
|
withScrollArea,
|
|
193
197
|
maxDropdownHeight,
|
|
194
|
-
unstyled
|
|
198
|
+
unstyled,
|
|
199
|
+
labelId: `${_id}-label`
|
|
195
200
|
}
|
|
196
201
|
)
|
|
197
202
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.js","sources":["../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n StylesApiProps,\n factory,\n ElementProps,\n useProps,\n Factory,\n useResolvedStylesApi,\n} from '../../core';\nimport { InputBase } from '../InputBase';\nimport { __InputStylesNames, __BaseInputProps, InputVariant } from '../Input';\nimport {\n Combobox,\n OptionsDropdown,\n useCombobox,\n getParsedComboboxData,\n getOptionsLockup,\n ComboboxLikeProps,\n ComboboxLikeStylesNames,\n} from '../Combobox';\n\nexport type AutocompleteStylesNames = __InputStylesNames | ComboboxLikeStylesNames;\n\nexport interface AutocompleteProps\n extends BoxProps,\n __BaseInputProps,\n ComboboxLikeProps,\n StylesApiProps<AutocompleteFactory>,\n ElementProps<'input', 'onChange' | 'size'> {\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?(value: string): void;\n}\n\nexport type AutocompleteFactory = Factory<{\n props: AutocompleteProps;\n ref: HTMLInputElement;\n stylesNames: AutocompleteStylesNames;\n variant: InputVariant;\n}>;\n\nconst defaultProps: Partial<AutocompleteProps> = {};\n\nexport const Autocomplete = factory<AutocompleteFactory>((_props, ref) => {\n const props = useProps('Autocomplete', defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n vars,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownClose,\n onDropdownOpen,\n onFocus,\n onBlur,\n onClick,\n onChange,\n data,\n value,\n defaultValue,\n selectFirstOptionOnChange,\n onOptionSubmit,\n comboboxProps,\n readOnly,\n disabled,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n size,\n ...others\n } = props;\n\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 onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\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 return (\n <Combobox\n store={combobox}\n __staticSelector=\"Autocomplete\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val);\n setValue(optionsLockup[val].label);\n combobox.closeDropdown();\n }}\n size={size}\n {...comboboxProps}\n >\n <Combobox.Target>\n <InputBase\n ref={ref}\n {...others}\n size={size}\n __staticSelector=\"Autocomplete\"\n disabled={disabled}\n readOnly={readOnly}\n value={_value}\n onChange={(event) => {\n setValue(event.currentTarget.value);\n combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n onFocus={(event) => {\n combobox.openDropdown();\n onFocus?.(event);\n }}\n onBlur={(event) => {\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 />\n </Combobox.Target>\n <OptionsDropdown\n data={parsedData}\n hidden={readOnly || disabled}\n filter={filter}\n search={_value}\n limit={limit}\n hiddenWhenEmpty\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n unstyled={unstyled}\n />\n </Combobox>\n );\n});\n\nAutocomplete.classes = { ...InputBase.classes, ...Combobox.classes };\nAutocomplete.displayName = '@mantine/core/Autocomplete';\n"],"names":["factory","useProps","getParsedComboboxData","getOptionsLockup","useUncontrolled","useCombobox","useResolvedStylesApi","useEffect","React","Combobox","InputBase","OptionsDropdown"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IA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,OAAO,EAAE,CAAC,KAAK,KAAK;AAC5B,UAAU,QAAQ,CAAC,YAAY,EAAE,CAAC;AAClC,UAAU,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACpD,SAAS;AACT,QAAQ,UAAU,EAAE,kBAAkB;AACtC,QAAQ,MAAM,EAAE,cAAc;AAC9B,QAAQ,QAAQ;AAChB,OAAO,CAAC;AACR,KAAK,CAAC;AACN,oBAAoBF,cAAK,CAAC,aAAa;AACvC,MAAMG,+BAAe;AACrB,MAAM;AACN,QAAQ,IAAI,EAAE,UAAU;AACxB,QAAQ,MAAM,EAAE,QAAQ,IAAI,QAAQ;AACpC,QAAQ,MAAM;AACd,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,KAAK;AACb,QAAQ,eAAe,EAAE,IAAI;AAC7B,QAAQ,cAAc;AACtB,QAAQ,iBAAiB;AACzB,QAAQ,QAAQ;AAChB,OAAO;AACP,KAAK;AACL,GAAG,CAAC;AACJ,CAAC,EAAE;AACH,YAAY,CAAC,OAAO,GAAG,cAAc,CAAC,cAAc,CAAC,EAAE,EAAED,mBAAS,CAAC,OAAO,CAAC,EAAED,iBAAQ,CAAC,OAAO,CAAC,CAAC;AAC/F,YAAY,CAAC,WAAW,GAAG,4BAA4B;;;;"}
|
|
1
|
+
{"version":3,"file":"Autocomplete.js","sources":["../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useUncontrolled, useId } from '@mantine/hooks';\nimport {\n BoxProps,\n StylesApiProps,\n factory,\n ElementProps,\n useProps,\n Factory,\n useResolvedStylesApi,\n} from '../../core';\nimport { InputBase } from '../InputBase';\nimport { __InputStylesNames, __BaseInputProps, InputVariant } from '../Input';\nimport {\n Combobox,\n OptionsDropdown,\n useCombobox,\n getParsedComboboxData,\n getOptionsLockup,\n ComboboxLikeProps,\n ComboboxLikeStylesNames,\n} from '../Combobox';\n\nexport type AutocompleteStylesNames = __InputStylesNames | ComboboxLikeStylesNames;\n\nexport interface AutocompleteProps\n extends BoxProps,\n __BaseInputProps,\n ComboboxLikeProps,\n StylesApiProps<AutocompleteFactory>,\n ElementProps<'input', 'onChange' | 'size'> {\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?(value: string): void;\n}\n\nexport type AutocompleteFactory = Factory<{\n props: AutocompleteProps;\n ref: HTMLInputElement;\n stylesNames: AutocompleteStylesNames;\n variant: InputVariant;\n}>;\n\nconst defaultProps: Partial<AutocompleteProps> = {};\n\nexport const Autocomplete = factory<AutocompleteFactory>((_props, ref) => {\n const props = useProps('Autocomplete', defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n vars,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownClose,\n onDropdownOpen,\n onFocus,\n onBlur,\n onClick,\n onChange,\n data,\n value,\n defaultValue,\n selectFirstOptionOnChange,\n onOptionSubmit,\n comboboxProps,\n readOnly,\n disabled,\n filter,\n limit,\n withScrollArea,\n maxDropdownHeight,\n size,\n id,\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 onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\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 return (\n <Combobox\n store={combobox}\n __staticSelector=\"Autocomplete\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n onOptionSubmit={(val) => {\n onOptionSubmit?.(val);\n setValue(optionsLockup[val].label);\n combobox.closeDropdown();\n }}\n size={size}\n {...comboboxProps}\n >\n <Combobox.Target>\n <InputBase\n ref={ref}\n {...others}\n size={size}\n __staticSelector=\"Autocomplete\"\n disabled={disabled}\n readOnly={readOnly}\n value={_value}\n onChange={(event) => {\n setValue(event.currentTarget.value);\n combobox.openDropdown();\n selectFirstOptionOnChange && combobox.selectFirstOption();\n }}\n onFocus={(event) => {\n combobox.openDropdown();\n onFocus?.(event);\n }}\n onBlur={(event) => {\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 id={_id}\n />\n </Combobox.Target>\n <OptionsDropdown\n data={parsedData}\n hidden={readOnly || disabled}\n filter={filter}\n search={_value}\n limit={limit}\n hiddenWhenEmpty\n withScrollArea={withScrollArea}\n maxDropdownHeight={maxDropdownHeight}\n unstyled={unstyled}\n labelId={`${_id}-label`}\n />\n </Combobox>\n );\n});\n\nAutocomplete.classes = { ...InputBase.classes, ...Combobox.classes };\nAutocomplete.displayName = '@mantine/core/Autocomplete';\n"],"names":["factory","useProps","useId","getParsedComboboxData","getOptionsLockup","useUncontrolled","useCombobox","useResolvedStylesApi","useEffect","React","Combobox","InputBase","OptionsDropdown"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;A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AAK;AACL,GAAG,CAAC;AACJ,CAAC,EAAE;AACH,YAAY,CAAC,OAAO,GAAG,cAAc,CAAC,cAAc,CAAC,EAAE,EAAED,mBAAS,CAAC,OAAO,CAAC,EAAED,iBAAQ,CAAC,OAAO,CAAC,CAAC;AAC/F,YAAY,CAAC,WAAW,GAAG,4BAA4B;;;;"}
|
|
@@ -45,10 +45,25 @@ const defaultProps = {
|
|
|
45
45
|
refProp: "ref",
|
|
46
46
|
targetType: "input",
|
|
47
47
|
withKeyboardNavigation: true,
|
|
48
|
-
withAriaAttributes: true
|
|
48
|
+
withAriaAttributes: true,
|
|
49
|
+
withExpandedAttribute: false
|
|
49
50
|
};
|
|
50
51
|
const ComboboxEventsTarget = factory.factory((props, ref) => {
|
|
51
|
-
const _a = useProps.useProps("ComboboxEventsTarget", defaultProps, props), {
|
|
52
|
+
const _a = useProps.useProps("ComboboxEventsTarget", defaultProps, props), {
|
|
53
|
+
children,
|
|
54
|
+
refProp,
|
|
55
|
+
withKeyboardNavigation,
|
|
56
|
+
withAriaAttributes,
|
|
57
|
+
withExpandedAttribute,
|
|
58
|
+
targetType
|
|
59
|
+
} = _a, others = __objRest(_a, [
|
|
60
|
+
"children",
|
|
61
|
+
"refProp",
|
|
62
|
+
"withKeyboardNavigation",
|
|
63
|
+
"withAriaAttributes",
|
|
64
|
+
"withExpandedAttribute",
|
|
65
|
+
"targetType"
|
|
66
|
+
]);
|
|
52
67
|
if (!isElement.isElement(children)) {
|
|
53
68
|
throw new Error(
|
|
54
69
|
"Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported"
|
|
@@ -59,6 +74,7 @@ const ComboboxEventsTarget = factory.factory((props, ref) => {
|
|
|
59
74
|
targetType,
|
|
60
75
|
withAriaAttributes,
|
|
61
76
|
withKeyboardNavigation,
|
|
77
|
+
withExpandedAttribute,
|
|
62
78
|
onKeyDown: children.props.onKeyDown
|
|
63
79
|
});
|
|
64
80
|
return React.cloneElement(children, __spreadProps(__spreadValues(__spreadValues({}, targetProps), others), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxEventsTarget.js","sources":["../../../../src/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport { isElement, useProps, factory, Factory } from '../../../core';\nimport { useComboboxTargetProps } from '../use-combobox-target-props/use-combobox-target-props';\nimport { useComboboxContext } from '../Combobox.context';\n\nexport interface ComboboxEventsTargetProps {\n /** Target element */\n children: React.ReactNode;\n\n /** Key of the prop that should be used to access element ref */\n refProp?: string;\n\n /** Determines whether component should respond to keyboard events, `true` by default */\n withKeyboardNavigation?: boolean;\n\n /** Determines whether the target should have `aria-` attributes, `true` by default */\n withAriaAttributes?: boolean;\n\n /** Determines which events should be handled by the target element.\n * `button` target type handles `Space` and `Enter` keys to toggle dropdown opened state.\n * `input` by default.\n * */\n targetType?: 'button' | 'input';\n}\n\nconst defaultProps: Partial<ComboboxEventsTargetProps> = {\n refProp: 'ref',\n targetType: 'input',\n withKeyboardNavigation: true,\n withAriaAttributes: true,\n};\n\nexport type ComboboxEventsTargetFactory = Factory<{\n props: ComboboxEventsTargetProps;\n ref: HTMLElement;\n compound: true;\n}>;\n\nexport const ComboboxEventsTarget = factory<ComboboxEventsTargetFactory>((props, ref) => {\n const {
|
|
1
|
+
{"version":3,"file":"ComboboxEventsTarget.js","sources":["../../../../src/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport { isElement, useProps, factory, Factory } from '../../../core';\nimport { useComboboxTargetProps } from '../use-combobox-target-props/use-combobox-target-props';\nimport { useComboboxContext } from '../Combobox.context';\n\nexport interface ComboboxEventsTargetProps {\n /** Target element */\n children: React.ReactNode;\n\n /** Key of the prop that should be used to access element ref */\n refProp?: string;\n\n /** Determines whether component should respond to keyboard events, `true` by default */\n withKeyboardNavigation?: boolean;\n\n /** Determines whether the target should have `aria-` attributes, `true` by default */\n withAriaAttributes?: boolean;\n\n /** Determines whether the target should have `aria-expanded` attribute, `false` by default */\n withExpandedAttribute?: boolean;\n\n /** Determines which events should be handled by the target element.\n * `button` target type handles `Space` and `Enter` keys to toggle dropdown opened state.\n * `input` by default.\n * */\n targetType?: 'button' | 'input';\n}\n\nconst defaultProps: Partial<ComboboxEventsTargetProps> = {\n refProp: 'ref',\n targetType: 'input',\n withKeyboardNavigation: true,\n withAriaAttributes: true,\n withExpandedAttribute: false,\n};\n\nexport type ComboboxEventsTargetFactory = Factory<{\n props: ComboboxEventsTargetProps;\n ref: HTMLElement;\n compound: true;\n}>;\n\nexport const ComboboxEventsTarget = factory<ComboboxEventsTargetFactory>((props, ref) => {\n const {\n children,\n refProp,\n withKeyboardNavigation,\n withAriaAttributes,\n withExpandedAttribute,\n targetType,\n ...others\n } = useProps('ComboboxEventsTarget', defaultProps, props);\n\n if (!isElement(children)) {\n throw new Error(\n 'Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported'\n );\n }\n\n const ctx = useComboboxContext();\n const targetProps = useComboboxTargetProps({\n targetType,\n withAriaAttributes,\n withKeyboardNavigation,\n withExpandedAttribute,\n onKeyDown: children.props.onKeyDown,\n });\n\n return cloneElement(children, {\n ...targetProps,\n ...others,\n [refProp!]: useMergedRef(ref, ctx.store.targetRef, (children as any)?.ref),\n });\n});\n\nComboboxEventsTarget.displayName = '@mantine/core/ComboboxEventsTarget';\n"],"names":["factory","useProps","isElement","useComboboxContext","useComboboxTargetProps","cloneElement","useMergedRef"],"mappings":";;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAA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AuB;AAC3B,IAAI,YAAY;AAChB,GAAG,CAAC,CAAC;AACL,EAAE,IAAI,CAACC,mBAAS,CAAC,QAAQ,CAAC,EAAE;AAC5B,IAAI,MAAM,IAAI,KAAK;AACnB,MAAM,yKAAyK;AAC/K,KAAK,CAAC;AACN,GAAG;AACH,EAAE,MAAM,GAAG,GAAGC,mCAAkB,EAAE,CAAC;AACnC,EAAE,MAAM,WAAW,GAAGC,6CAAsB,CAAC;AAC7C,IAAI,UAAU;AACd,IAAI,kBAAkB;AACtB,IAAI,sBAAsB;AAC1B,IAAI,qBAAqB;AACzB,IAAI,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;AACvC,GAAG,CAAC,CAAC;AACL,EAAE,OAAOC,kBAAY,CAAC,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,EAAE;AACvG,IAAI,CAAC,OAAO,GAAGC,kBAAY,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC;AAC/F,GAAG,CAAC,CAAC,CAAC;AACN,CAAC,EAAE;AACH,oBAAoB,CAAC,WAAW,GAAG,oCAAoC;;;;"}
|
|
@@ -48,7 +48,7 @@ var __objRest = (source, exclude) => {
|
|
|
48
48
|
const defaultProps = {};
|
|
49
49
|
const ComboboxOptions = factory.factory((_props, ref) => {
|
|
50
50
|
const props = useProps.useProps("ComboboxOptions", defaultProps, _props);
|
|
51
|
-
const _a = props, { classNames, className, style, styles, id, onMouseDown } = _a, others = __objRest(_a, ["classNames", "className", "style", "styles", "id", "onMouseDown"]);
|
|
51
|
+
const _a = props, { classNames, className, style, styles, id, onMouseDown, labelledBy } = _a, others = __objRest(_a, ["classNames", "className", "style", "styles", "id", "onMouseDown", "labelledBy"]);
|
|
52
52
|
const ctx = Combobox_context.useComboboxContext();
|
|
53
53
|
const _id = hooks.useId(id);
|
|
54
54
|
React.useEffect(() => {
|
|
@@ -61,6 +61,7 @@ const ComboboxOptions = factory.factory((_props, ref) => {
|
|
|
61
61
|
}, ctx.getStyles("options", { className, style, classNames, styles })), others), {
|
|
62
62
|
id: _id,
|
|
63
63
|
role: "listbox",
|
|
64
|
+
"aria-labelledby": labelledBy,
|
|
64
65
|
onMouseDown: (event) => {
|
|
65
66
|
event.preventDefault();
|
|
66
67
|
onMouseDown == null ? void 0 : onMouseDown(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxOptions.js","sources":["../../../../src/components/Combobox/ComboboxOptions/ComboboxOptions.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useId } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n CompoundStylesApiProps,\n factory,\n ElementProps,\n useProps,\n Factory,\n} from '../../../core';\nimport { useComboboxContext } from '../Combobox.context';\nimport classes from '../Combobox.module.css';\n\nexport type ComboboxOptionsStylesNames = 'options';\n\nexport interface ComboboxOptionsProps\n extends BoxProps,\n CompoundStylesApiProps<ComboboxOptionsFactory>,\n ElementProps<'div'> {}\n\nexport type ComboboxOptionsFactory = Factory<{\n props: ComboboxOptionsProps;\n ref: HTMLDivElement;\n stylesNames: ComboboxOptionsStylesNames;\n compound: true;\n}>;\n\nconst defaultProps: Partial<ComboboxOptionsProps> = {};\n\nexport const ComboboxOptions = factory<ComboboxOptionsFactory>((_props, ref) => {\n const props = useProps('ComboboxOptions', defaultProps, _props);\n const { classNames, className, style, styles, id, onMouseDown, ...others } = props;\n const ctx = useComboboxContext();\n const _id = useId(id);\n\n useEffect(() => {\n ctx.store.setListId(_id);\n }, [_id]);\n\n return (\n <Box\n ref={ref}\n {...ctx.getStyles('options', { className, style, classNames, styles })}\n {...others}\n id={_id}\n role=\"listbox\"\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n }}\n />\n );\n});\n\nComboboxOptions.classes = classes;\nComboboxOptions.displayName = '@mantine/core/ComboboxOptions';\n"],"names":["factory","useProps","useComboboxContext","useId","useEffect","React","Box","classes"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAA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AAS,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ComboboxOptions.js","sources":["../../../../src/components/Combobox/ComboboxOptions/ComboboxOptions.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useId } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n CompoundStylesApiProps,\n factory,\n ElementProps,\n useProps,\n Factory,\n} from '../../../core';\nimport { useComboboxContext } from '../Combobox.context';\nimport classes from '../Combobox.module.css';\n\nexport type ComboboxOptionsStylesNames = 'options';\n\nexport interface ComboboxOptionsProps\n extends BoxProps,\n CompoundStylesApiProps<ComboboxOptionsFactory>,\n ElementProps<'div'> {\n /** Id of the element that should label the options list */\n labelledBy?: string;\n}\n\nexport type ComboboxOptionsFactory = Factory<{\n props: ComboboxOptionsProps;\n ref: HTMLDivElement;\n stylesNames: ComboboxOptionsStylesNames;\n compound: true;\n}>;\n\nconst defaultProps: Partial<ComboboxOptionsProps> = {};\n\nexport const ComboboxOptions = factory<ComboboxOptionsFactory>((_props, ref) => {\n const props = useProps('ComboboxOptions', defaultProps, _props);\n const { classNames, className, style, styles, id, onMouseDown, labelledBy, ...others } = props;\n const ctx = useComboboxContext();\n const _id = useId(id);\n\n useEffect(() => {\n ctx.store.setListId(_id);\n }, [_id]);\n\n return (\n <Box\n ref={ref}\n {...ctx.getStyles('options', { className, style, classNames, styles })}\n {...others}\n id={_id}\n role=\"listbox\"\n aria-labelledby={labelledBy}\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n }}\n />\n );\n});\n\nComboboxOptions.classes = classes;\nComboboxOptions.displayName = '@mantine/core/ComboboxOptions';\n"],"names":["factory","useProps","useComboboxContext","useId","useEffect","React","Box","classes"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,I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mCAAkB,EAAE,CAAC;AACnC,EAAE,MAAM,GAAG,GAAGC,WAAK,CAAC,EAAE,CAAC,CAAC;AACxB,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7B,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACZ,EAAE,uBAAuBC,cAAK,CAAC,aAAa;AAC5C,IAAIC,OAAG;AACP,IAAI,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAChD,MAAM,GAAG;AACT,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE;AACrF,MAAM,EAAE,EAAE,GAAG;AACb,MAAM,IAAI,EAAE,SAAS;AACrB,MAAM,iBAAiB,EAAE,UAAU;AACnC,MAAM,WAAW,EAAE,CAAC,KAAK,KAAK;AAC9B,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;AAC/B,QAAQ,WAAW,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;AAC1D,OAAO;AACP,KAAK,CAAC;AACN,GAAG,CAAC;AACJ,CAAC,EAAE;AACH,eAAe,CAAC,OAAO,GAAGC,0BAAO,CAAC;AAClC,eAAe,CAAC,WAAW,GAAG,+BAA+B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxSearch.js","sources":["../../../../src/components/Combobox/ComboboxSearch/ComboboxSearch.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport { factory, ElementProps, useProps, Factory } from '../../../core';\nimport { Input, InputProps, InputStylesNames } from '../../Input/Input';\nimport { useComboboxContext } from '../Combobox.context';\nimport { useComboboxTargetProps } from '../use-combobox-target-props/use-combobox-target-props';\nimport classes from '../Combobox.module.css';\n\nexport type ComboboxSearchStylesNames = InputStylesNames;\n\nexport interface ComboboxSearchProps extends InputProps, ElementProps<'input', 'size'> {\n /** Determines whether the search input should have `aria-` attribute, `true` by default */\n withAriaAttributes?: boolean;\n\n /** Determines whether the search input should handle keyboard navigation, `true` by default */\n withKeyboardNavigation?: boolean;\n}\n\nexport type ComboboxSearchFactory = Factory<{\n props: ComboboxSearchProps;\n ref: HTMLInputElement;\n stylesNames: ComboboxSearchStylesNames;\n}>;\n\nconst defaultProps: Partial<ComboboxSearchProps> = {\n withAriaAttributes: true,\n withKeyboardNavigation: true,\n};\n\nexport const ComboboxSearch = factory<ComboboxSearchFactory>((_props, ref) => {\n const props = useProps('ComboboxSearch', defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n vars,\n withAriaAttributes,\n onKeyDown,\n withKeyboardNavigation,\n size,\n ...others\n } = props;\n\n const ctx = useComboboxContext();\n const _styles = ctx.getStyles('search');\n\n const targetProps = useComboboxTargetProps({\n targetType: 'input',\n withAriaAttributes,\n withKeyboardNavigation,\n onKeyDown,\n });\n\n return (\n <Input\n ref={useMergedRef(ref, ctx.store.searchRef)}\n classNames={[{ input: _styles.className }, classNames] as any}\n styles={[{ input: _styles.style }, styles] as any}\n size={size || ctx.size}\n {...targetProps}\n {...others}\n __staticSelector=\"Combobox\"\n />\n );\n});\n\nComboboxSearch.classes = classes;\nComboboxSearch.displayName = '@mantine/core/ComboboxSearch';\n"],"names":["factory","useProps","useComboboxContext","useComboboxTargetProps","React","Input","useMergedRef","classes"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC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,GAAGC,mCAAkB,EAAE,CAAC;AACnC,EAAE,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,EAAE,MAAM,WAAW,GAAGC,6CAAsB,CAAC;AAC7C,IAAI,UAAU,EAAE,OAAO;AACvB,IAAI,kBAAkB;AACtB,IAAI,sBAAsB;AAC1B,IAAI,SAAS;AACb,GAAG,CAAC,CAAC;AACL,EAAE,uBAAuBC,cAAK,CAAC,aAAa;AAC5C,IAAIC,WAAK;AACT,IAAI,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAChD,MAAM,GAAG,EAAEC,kBAAY,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC;AACjD,MAAM,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC;AAC5D,MAAM,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC;AAChD,MAAM,IAAI,EAAE,IAAI,IAAI,GAAG,CAAC,IAAI;AAC5B,KAAK,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,EAAE;AAC9B,MAAM,gBAAgB,EAAE,UAAU;AAClC,KAAK,CAAC;AACN,GAAG,CAAC;AACJ,CAAC,EAAE;AACH,cAAc,CAAC,OAAO,GAAGC,0BAAO,CAAC;AACjC,cAAc,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
|
1
|
+
{"version":3,"file":"ComboboxSearch.js","sources":["../../../../src/components/Combobox/ComboboxSearch/ComboboxSearch.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport { factory, ElementProps, useProps, Factory } from '../../../core';\nimport { Input, InputProps, InputStylesNames } from '../../Input/Input';\nimport { useComboboxContext } from '../Combobox.context';\nimport { useComboboxTargetProps } from '../use-combobox-target-props/use-combobox-target-props';\nimport classes from '../Combobox.module.css';\n\nexport type ComboboxSearchStylesNames = InputStylesNames;\n\nexport interface ComboboxSearchProps extends InputProps, ElementProps<'input', 'size'> {\n /** Determines whether the search input should have `aria-` attribute, `true` by default */\n withAriaAttributes?: boolean;\n\n /** Determines whether the search input should handle keyboard navigation, `true` by default */\n withKeyboardNavigation?: boolean;\n}\n\nexport type ComboboxSearchFactory = Factory<{\n props: ComboboxSearchProps;\n ref: HTMLInputElement;\n stylesNames: ComboboxSearchStylesNames;\n}>;\n\nconst defaultProps: Partial<ComboboxSearchProps> = {\n withAriaAttributes: true,\n withKeyboardNavigation: true,\n};\n\nexport const ComboboxSearch = factory<ComboboxSearchFactory>((_props, ref) => {\n const props = useProps('ComboboxSearch', defaultProps, _props);\n const {\n classNames,\n styles,\n unstyled,\n vars,\n withAriaAttributes,\n onKeyDown,\n withKeyboardNavigation,\n size,\n ...others\n } = props;\n\n const ctx = useComboboxContext();\n const _styles = ctx.getStyles('search');\n\n const targetProps = useComboboxTargetProps({\n targetType: 'input',\n withAriaAttributes,\n withKeyboardNavigation,\n withExpandedAttribute: false,\n onKeyDown,\n });\n\n return (\n <Input\n ref={useMergedRef(ref, ctx.store.searchRef)}\n classNames={[{ input: _styles.className }, classNames] as any}\n styles={[{ input: _styles.style }, styles] as any}\n size={size || ctx.size}\n {...targetProps}\n {...others}\n __staticSelector=\"Combobox\"\n />\n );\n});\n\nComboboxSearch.classes = classes;\nComboboxSearch.displayName = '@mantine/core/ComboboxSearch';\n"],"names":["factory","useProps","useComboboxContext","useComboboxTargetProps","React","Input","useMergedRef","classes"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CA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AG,GAAGC,mCAAkB,EAAE,CAAC;AACnC,EAAE,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,EAAE,MAAM,WAAW,GAAGC,6CAAsB,CAAC;AAC7C,IAAI,UAAU,EAAE,OAAO;AACvB,IAAI,kBAAkB;AACtB,IAAI,sBAAsB;AAC1B,IAAI,qBAAqB,EAAE,KAAK;AAChC,IAAI,SAAS;AACb,GAAG,CAAC,CAAC;AACL,EAAE,uBAAuBC,cAAK,CAAC,aAAa;AAC5C,IAAIC,WAAK;AACT,IAAI,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAChD,MAAM,GAAG,EAAEC,kBAAY,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC;AACjD,MAAM,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC;AAC5D,MAAM,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC;AAChD,MAAM,IAAI,EAAE,IAAI,IAAI,GAAG,CAAC,IAAI;AAC5B,KAAK,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,EAAE;AAC9B,MAAM,gBAAgB,EAAE,UAAU;AAClC,KAAK,CAAC;AACN,GAAG,CAAC;AACJ,CAAC,EAAE;AACH,cAAc,CAAC,OAAO,GAAGC,0BAAO,CAAC;AACjC,cAAc,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
|
@@ -47,10 +47,25 @@ const defaultProps = {
|
|
|
47
47
|
refProp: "ref",
|
|
48
48
|
targetType: "input",
|
|
49
49
|
withKeyboardNavigation: true,
|
|
50
|
-
withAriaAttributes: true
|
|
50
|
+
withAriaAttributes: true,
|
|
51
|
+
withExpandedAttribute: false
|
|
51
52
|
};
|
|
52
53
|
const ComboboxTarget = factory.factory((props, ref) => {
|
|
53
|
-
const _a = useProps.useProps("ComboboxTarget", defaultProps, props), {
|
|
54
|
+
const _a = useProps.useProps("ComboboxTarget", defaultProps, props), {
|
|
55
|
+
children,
|
|
56
|
+
refProp,
|
|
57
|
+
withKeyboardNavigation,
|
|
58
|
+
withAriaAttributes,
|
|
59
|
+
withExpandedAttribute,
|
|
60
|
+
targetType
|
|
61
|
+
} = _a, others = __objRest(_a, [
|
|
62
|
+
"children",
|
|
63
|
+
"refProp",
|
|
64
|
+
"withKeyboardNavigation",
|
|
65
|
+
"withAriaAttributes",
|
|
66
|
+
"withExpandedAttribute",
|
|
67
|
+
"targetType"
|
|
68
|
+
]);
|
|
54
69
|
if (!isElement.isElement(children)) {
|
|
55
70
|
throw new Error(
|
|
56
71
|
"Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported"
|
|
@@ -61,6 +76,7 @@ const ComboboxTarget = factory.factory((props, ref) => {
|
|
|
61
76
|
targetType,
|
|
62
77
|
withAriaAttributes,
|
|
63
78
|
withKeyboardNavigation,
|
|
79
|
+
withExpandedAttribute,
|
|
64
80
|
onKeyDown: children.props.onKeyDown
|
|
65
81
|
});
|
|
66
82
|
const clonedElement = React.cloneElement(children, __spreadValues(__spreadValues({}, targetProps), others));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxTarget.js","sources":["../../../../src/components/Combobox/ComboboxTarget/ComboboxTarget.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport { Popover } from '../../Popover';\nimport { isElement, useProps, factory, Factory } from '../../../core';\nimport { useComboboxContext } from '../Combobox.context';\nimport { useComboboxTargetProps } from '../use-combobox-target-props/use-combobox-target-props';\n\nexport interface ComboboxTargetProps {\n /** Target element */\n children: React.ReactNode;\n\n /** Key of the prop that should be used to access element ref */\n refProp?: string;\n\n /** Determines whether component should respond to keyboard events, `true` by default */\n withKeyboardNavigation?: boolean;\n\n /** Determines whether the target should have `aria-` attributes, `true` by default */\n withAriaAttributes?: boolean;\n\n /** Determines which events should be handled by the target element.\n * `button` target type handles `Space` and `Enter` keys to toggle dropdown opened state.\n * `input` by default.\n * */\n targetType?: 'button' | 'input';\n}\n\nconst defaultProps: Partial<ComboboxTargetProps> = {\n refProp: 'ref',\n targetType: 'input',\n withKeyboardNavigation: true,\n withAriaAttributes: true,\n};\n\nexport type ComboboxTargetFactory = Factory<{\n props: ComboboxTargetProps;\n ref: HTMLElement;\n compound: true;\n}>;\n\nexport const ComboboxTarget = factory<ComboboxTargetFactory>((props, ref) => {\n const {
|
|
1
|
+
{"version":3,"file":"ComboboxTarget.js","sources":["../../../../src/components/Combobox/ComboboxTarget/ComboboxTarget.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport { Popover } from '../../Popover';\nimport { isElement, useProps, factory, Factory } from '../../../core';\nimport { useComboboxContext } from '../Combobox.context';\nimport { useComboboxTargetProps } from '../use-combobox-target-props/use-combobox-target-props';\n\nexport interface ComboboxTargetProps {\n /** Target element */\n children: React.ReactNode;\n\n /** Key of the prop that should be used to access element ref */\n refProp?: string;\n\n /** Determines whether component should respond to keyboard events, `true` by default */\n withKeyboardNavigation?: boolean;\n\n /** Determines whether the target should have `aria-` attributes, `true` by default */\n withAriaAttributes?: boolean;\n\n /** Determines whether the target should have `aria-expanded` attribute, `false` by default */\n withExpandedAttribute?: boolean;\n\n /** Determines which events should be handled by the target element.\n * `button` target type handles `Space` and `Enter` keys to toggle dropdown opened state.\n * `input` by default.\n * */\n targetType?: 'button' | 'input';\n}\n\nconst defaultProps: Partial<ComboboxTargetProps> = {\n refProp: 'ref',\n targetType: 'input',\n withKeyboardNavigation: true,\n withAriaAttributes: true,\n withExpandedAttribute: false,\n};\n\nexport type ComboboxTargetFactory = Factory<{\n props: ComboboxTargetProps;\n ref: HTMLElement;\n compound: true;\n}>;\n\nexport const ComboboxTarget = factory<ComboboxTargetFactory>((props, ref) => {\n const {\n children,\n refProp,\n withKeyboardNavigation,\n withAriaAttributes,\n withExpandedAttribute,\n targetType,\n ...others\n } = useProps('ComboboxTarget', defaultProps, props);\n\n if (!isElement(children)) {\n throw new Error(\n 'Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported'\n );\n }\n\n const ctx = useComboboxContext();\n\n const targetProps = useComboboxTargetProps({\n targetType,\n withAriaAttributes,\n withKeyboardNavigation,\n withExpandedAttribute,\n onKeyDown: children.props.onKeyDown,\n });\n\n const clonedElement = cloneElement(children, {\n ...targetProps,\n ...others,\n });\n\n return (\n <Popover.Target ref={useMergedRef(ref, ctx.store.targetRef)}>{clonedElement}</Popover.Target>\n );\n});\n\nComboboxTarget.displayName = '@mantine/core/ComboboxTarget';\n"],"names":["factory","useProps","isElement","useComboboxContext","useComboboxTargetProps","cloneElement","React","Popover","useMergedRef"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAA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AE,EAAE,aAAa,CAAC,CAAC;AAC7H,CAAC,EAAE;AACH,cAAc,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
|
@@ -31,7 +31,8 @@ function Option({ data, withCheckIcon, value, checkIconPosition, unstyled }) {
|
|
|
31
31
|
disabled: data.disabled,
|
|
32
32
|
className: cx__default({ [Combobox_module['default'].optionsDropdownOption]: !unstyled }),
|
|
33
33
|
"data-reverse": checkIconPosition === "right" || void 0,
|
|
34
|
-
"data-checked": isValueChecked(value, data.value) || void 0
|
|
34
|
+
"data-checked": isValueChecked(value, data.value) || void 0,
|
|
35
|
+
"aria-selected": isValueChecked(value, data.value)
|
|
35
36
|
},
|
|
36
37
|
checkIconPosition === "left" && check,
|
|
37
38
|
data.label,
|
|
@@ -55,7 +56,8 @@ function OptionsDropdown({
|
|
|
55
56
|
value,
|
|
56
57
|
checkIconPosition,
|
|
57
58
|
nothingFoundMessage,
|
|
58
|
-
unstyled
|
|
59
|
+
unstyled,
|
|
60
|
+
labelId
|
|
59
61
|
}) {
|
|
60
62
|
validateOptions.validateOptions(data);
|
|
61
63
|
const shouldFilter = typeof search === "string";
|
|
@@ -76,7 +78,7 @@ function OptionsDropdown({
|
|
|
76
78
|
unstyled
|
|
77
79
|
}
|
|
78
80
|
));
|
|
79
|
-
return /* @__PURE__ */ React__default.createElement(Combobox.Combobox.Dropdown, { hidden: hidden || hiddenWhenEmpty && isEmpty }, /* @__PURE__ */ React__default.createElement(Combobox.Combobox.Options,
|
|
81
|
+
return /* @__PURE__ */ React__default.createElement(Combobox.Combobox.Dropdown, { hidden: hidden || hiddenWhenEmpty && isEmpty }, /* @__PURE__ */ React__default.createElement(Combobox.Combobox.Options, { labelledBy: labelId }, withScrollArea ? /* @__PURE__ */ React__default.createElement(
|
|
80
82
|
ScrollArea.ScrollArea.Autosize,
|
|
81
83
|
{
|
|
82
84
|
mah: maxDropdownHeight != null ? maxDropdownHeight : 220,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionsDropdown.js","sources":["../../../../src/components/Combobox/OptionsDropdown/OptionsDropdown.tsx"],"sourcesContent":["import React from 'react';\nimport cx from 'clsx';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { CheckIcon } from '../../Checkbox';\nimport { Combobox } from '../Combobox';\nimport { ComboboxItem, ComboboxParsedItem } from '../Combobox.types';\nimport { defaultOptionsFilter, FilterOptionsInput } from './default-options-filter';\nimport { isEmptyComboboxData } from './is-empty-combobox-data';\nimport { isOptionsGroup } from './is-options-group';\nimport { validateOptions } from './validate-options';\nimport classes from '../Combobox.module.css';\n\nexport type OptionsFilter = (input: FilterOptionsInput) => ComboboxParsedItem[];\n\nexport interface OptionsGroup {\n group: string;\n items: ComboboxItem[];\n}\n\nexport type OptionsData = (ComboboxItem | OptionsGroup)[];\n\ninterface OptionProps {\n data: ComboboxItem | OptionsGroup;\n withCheckIcon?: boolean;\n value?: string | string[] | null;\n checkIconPosition?: 'left' | 'right';\n unstyled: boolean | undefined;\n}\n\nfunction isValueChecked(value: string | string[] | undefined | null, optionValue: string) {\n return Array.isArray(value) ? value.includes(optionValue) : value === optionValue;\n}\n\nfunction Option({ data, withCheckIcon, value, checkIconPosition, unstyled }: OptionProps) {\n if (!isOptionsGroup(data)) {\n const check = withCheckIcon && isValueChecked(value, data.value) && (\n <CheckIcon className={classes.optionsDropdownCheckIcon} />\n );\n return (\n <Combobox.Option\n value={data.value}\n disabled={data.disabled}\n className={cx({ [classes.optionsDropdownOption]: !unstyled })}\n data-reverse={checkIconPosition === 'right' || undefined}\n data-checked={isValueChecked(value, data.value) || undefined}\n >\n {checkIconPosition === 'left' && check}\n {data.label}\n {checkIconPosition === 'right' && check}\n </Combobox.Option>\n );\n }\n\n const options = data.items.map((item) => (\n <Option data={item} key={item.value} unstyled={unstyled} />\n ));\n\n return <Combobox.Group label={data.group}>{options}</Combobox.Group>;\n}\n\nexport interface OptionsDropdownProps {\n data: OptionsData;\n filter: OptionsFilter | undefined;\n search: string | undefined;\n limit: number | undefined;\n withScrollArea: boolean | undefined;\n maxDropdownHeight: number | string | undefined;\n hidden?: boolean;\n hiddenWhenEmpty?: boolean;\n filterOptions?: boolean;\n withCheckIcon?: boolean;\n value?: string | string[] | null;\n checkIconPosition?: 'left' | 'right';\n nothingFoundMessage?: React.ReactNode;\n unstyled: boolean | undefined;\n}\n\nexport function OptionsDropdown({\n data,\n hidden,\n hiddenWhenEmpty,\n filter,\n search,\n limit,\n maxDropdownHeight,\n withScrollArea = true,\n filterOptions = true,\n withCheckIcon = false,\n value,\n checkIconPosition,\n nothingFoundMessage,\n unstyled,\n}: OptionsDropdownProps) {\n validateOptions(data);\n\n const shouldFilter = typeof search === 'string';\n const filteredData = shouldFilter\n ? (filter || defaultOptionsFilter)({\n options: data,\n search: filterOptions ? search : '',\n limit: limit ?? Infinity,\n })\n : data;\n const isEmpty = isEmptyComboboxData(filteredData);\n\n const options = filteredData.map((item) => (\n <Option\n data={item}\n key={isOptionsGroup(item) ? item.group : item.value}\n withCheckIcon={withCheckIcon}\n value={value}\n checkIconPosition={checkIconPosition}\n unstyled={unstyled}\n />\n ));\n\n return (\n <Combobox.Dropdown hidden={hidden || (hiddenWhenEmpty && isEmpty)}>\n <Combobox.Options>\n {withScrollArea ? (\n <ScrollArea.Autosize\n mah={maxDropdownHeight ?? 220}\n type=\"scroll\"\n scrollbarSize=\"var(--_combobox-padding)\"\n offsetScrollbars=\"y\"\n className={classes.optionsDropdownScrollArea}\n >\n {options}\n </ScrollArea.Autosize>\n ) : (\n options\n )}\n {isEmpty && nothingFoundMessage && <Combobox.Empty>{nothingFoundMessage}</Combobox.Empty>}\n </Combobox.Options>\n </Combobox.Dropdown>\n );\n}\n"],"names":["isOptionsGroup","React","CheckIcon","classes","Combobox","cx","validateOptions","defaultOptionsFilter","isEmptyComboboxData","ScrollArea"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUA,SAAS,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE;AAC5C,EAAE,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zD,MAAM,aAAa;AACnB,MAAM,KAAK;AACX,MAAM,iBAAiB;AACvB,MAAM,QAAQ;AACd,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,uBAAuBC,cAAK,CAAC,aAAa,CAACG,iBAAQ,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,IAAI,eAAe,IAAI,OAAO,EAAE,kBAAkBH,cAAK,CAAC,aAAa,CAACG,iBAAQ,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OptionsDropdown.js","sources":["../../../../src/components/Combobox/OptionsDropdown/OptionsDropdown.tsx"],"sourcesContent":["import React from 'react';\nimport cx from 'clsx';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { CheckIcon } from '../../Checkbox';\nimport { Combobox } from '../Combobox';\nimport { ComboboxItem, ComboboxParsedItem } from '../Combobox.types';\nimport { defaultOptionsFilter, FilterOptionsInput } from './default-options-filter';\nimport { isEmptyComboboxData } from './is-empty-combobox-data';\nimport { isOptionsGroup } from './is-options-group';\nimport { validateOptions } from './validate-options';\nimport classes from '../Combobox.module.css';\n\nexport type OptionsFilter = (input: FilterOptionsInput) => ComboboxParsedItem[];\n\nexport interface OptionsGroup {\n group: string;\n items: ComboboxItem[];\n}\n\nexport type OptionsData = (ComboboxItem | OptionsGroup)[];\n\ninterface OptionProps {\n data: ComboboxItem | OptionsGroup;\n withCheckIcon?: boolean;\n value?: string | string[] | null;\n checkIconPosition?: 'left' | 'right';\n unstyled: boolean | undefined;\n}\n\nfunction isValueChecked(value: string | string[] | undefined | null, optionValue: string) {\n return Array.isArray(value) ? value.includes(optionValue) : value === optionValue;\n}\n\nfunction Option({ data, withCheckIcon, value, checkIconPosition, unstyled }: OptionProps) {\n if (!isOptionsGroup(data)) {\n const check = withCheckIcon && isValueChecked(value, data.value) && (\n <CheckIcon className={classes.optionsDropdownCheckIcon} />\n );\n return (\n <Combobox.Option\n value={data.value}\n disabled={data.disabled}\n className={cx({ [classes.optionsDropdownOption]: !unstyled })}\n data-reverse={checkIconPosition === 'right' || undefined}\n data-checked={isValueChecked(value, data.value) || undefined}\n aria-selected={isValueChecked(value, data.value)}\n >\n {checkIconPosition === 'left' && check}\n {data.label}\n {checkIconPosition === 'right' && check}\n </Combobox.Option>\n );\n }\n\n const options = data.items.map((item) => (\n <Option data={item} key={item.value} unstyled={unstyled} />\n ));\n\n return <Combobox.Group label={data.group}>{options}</Combobox.Group>;\n}\n\nexport interface OptionsDropdownProps {\n data: OptionsData;\n filter: OptionsFilter | undefined;\n search: string | undefined;\n limit: number | undefined;\n withScrollArea: boolean | undefined;\n maxDropdownHeight: number | string | undefined;\n hidden?: boolean;\n hiddenWhenEmpty?: boolean;\n filterOptions?: boolean;\n withCheckIcon?: boolean;\n value?: string | string[] | null;\n checkIconPosition?: 'left' | 'right';\n nothingFoundMessage?: React.ReactNode;\n unstyled: boolean | undefined;\n labelId: string;\n}\n\nexport function OptionsDropdown({\n data,\n hidden,\n hiddenWhenEmpty,\n filter,\n search,\n limit,\n maxDropdownHeight,\n withScrollArea = true,\n filterOptions = true,\n withCheckIcon = false,\n value,\n checkIconPosition,\n nothingFoundMessage,\n unstyled,\n labelId,\n}: OptionsDropdownProps) {\n validateOptions(data);\n\n const shouldFilter = typeof search === 'string';\n const filteredData = shouldFilter\n ? (filter || defaultOptionsFilter)({\n options: data,\n search: filterOptions ? search : '',\n limit: limit ?? Infinity,\n })\n : data;\n const isEmpty = isEmptyComboboxData(filteredData);\n\n const options = filteredData.map((item) => (\n <Option\n data={item}\n key={isOptionsGroup(item) ? item.group : item.value}\n withCheckIcon={withCheckIcon}\n value={value}\n checkIconPosition={checkIconPosition}\n unstyled={unstyled}\n />\n ));\n\n return (\n <Combobox.Dropdown hidden={hidden || (hiddenWhenEmpty && isEmpty)}>\n <Combobox.Options labelledBy={labelId}>\n {withScrollArea ? (\n <ScrollArea.Autosize\n mah={maxDropdownHeight ?? 220}\n type=\"scroll\"\n scrollbarSize=\"var(--_combobox-padding)\"\n offsetScrollbars=\"y\"\n className={classes.optionsDropdownScrollArea}\n >\n {options}\n </ScrollArea.Autosize>\n ) : (\n options\n )}\n {isEmpty && nothingFoundMessage && <Combobox.Empty>{nothingFoundMessage}</Combobox.Empty>}\n </Combobox.Options>\n </Combobox.Dropdown>\n );\n}\n"],"names":["isOptionsGroup","React","CheckIcon","classes","Combobox","cx","validateOptions","defaultOptionsFilter","isEmptyComboboxData","ScrollArea"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUA,SAAS,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE;AAC5C,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,KAAK,KAAK,WAAW,CAAC;AACpF,CAAC;AACD,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE;AAC7E,EAAE,IAAI,CAACA,6BAAc,CAAC,IAAI,CAAC,EAAE;AAC7B,IAAI,MAAM,KAAK,GAAG,aAAa,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,oBAAoBC,cAAK,CAAC,aAAa,CAACC,mBAAS,EAAE,EAAE,SAAS,EAAEC,0BAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;AACxK,IAAI,uBAAuBF,cAAK,CAAC,aAAa;AAC9C,MAAMG,iBAAQ,CAAC,MAAM;AACrB,MAAM;AACN,QAAQ,KAAK,EAAE,IAAI,CAAC,KAAK;AACzB,QAAQ,QAAQ,EAAE,IAAI,CAAC,QAAQ;AAC/B,QAAQ,SAAS,EAAEC,WAAE,CAAC,EAAE,CAACF,0BAAO,CAAC,qBAAqB,GAAG,CAAC,QAAQ,EAAE,CAAC;AACrE,QAAQ,cAAc,EAAE,iBAAiB,KAAK,OAAO,IAAI,KAAK,CAAC;AAC/D,QAAQ,cAAc,EAAE,cAAc,CAAC,KA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AAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAClI;;;;"}
|
|
@@ -28,6 +28,7 @@ function useComboboxTargetProps({
|
|
|
28
28
|
onKeyDown,
|
|
29
29
|
withKeyboardNavigation,
|
|
30
30
|
withAriaAttributes,
|
|
31
|
+
withExpandedAttribute,
|
|
31
32
|
targetType
|
|
32
33
|
}) {
|
|
33
34
|
const ctx = Combobox_context.useComboboxContext();
|
|
@@ -78,7 +79,7 @@ function useComboboxTargetProps({
|
|
|
78
79
|
};
|
|
79
80
|
const ariaAttributes = withAriaAttributes ? {
|
|
80
81
|
"aria-haspopup": "listbox",
|
|
81
|
-
"aria-expanded": ctx.store.listId
|
|
82
|
+
"aria-expanded": withExpandedAttribute && !!(ctx.store.listId && ctx.store.dropdownOpened) || void 0,
|
|
82
83
|
"aria-controls": ctx.store.listId,
|
|
83
84
|
"aria-activedescendant": ctx.store.dropdownOpened ? selectedOptionId || void 0 : void 0,
|
|
84
85
|
autoComplete: "off",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-combobox-target-props.js","sources":["../../../../src/components/Combobox/use-combobox-target-props/use-combobox-target-props.ts"],"sourcesContent":["import { useState } from 'react';\nimport { useComboboxContext } from '../Combobox.context';\n\ninterface UseComboboxTargetPropsInput {\n targetType: 'input' | 'button' | undefined;\n withAriaAttributes: boolean | undefined;\n withKeyboardNavigation: boolean | undefined;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement> | undefined;\n}\n\nexport function useComboboxTargetProps({\n onKeyDown,\n withKeyboardNavigation,\n withAriaAttributes,\n targetType,\n}: UseComboboxTargetPropsInput) {\n const ctx = useComboboxContext();\n const [selectedOptionId, setSelectedOptionId] = useState<string | null>(null);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (ctx.readOnly) {\n return;\n }\n\n if (withKeyboardNavigation) {\n if (event.nativeEvent.code === 'ArrowDown') {\n event.preventDefault();\n\n if (!ctx.store.dropdownOpened) {\n ctx.store.openDropdown('keyboard');\n setSelectedOptionId(ctx.store.selectActiveOption());\n } else {\n setSelectedOptionId(ctx.store.selectNextOption());\n }\n }\n\n if (event.nativeEvent.code === 'ArrowUp') {\n event.preventDefault();\n\n if (!ctx.store.dropdownOpened) {\n ctx.store.openDropdown('keyboard');\n setSelectedOptionId(ctx.store.selectActiveOption());\n } else {\n setSelectedOptionId(ctx.store.selectPreviousOption());\n }\n }\n\n if (event.nativeEvent.code === 'Enter') {\n if (ctx.store.dropdownOpened) {\n event.preventDefault();\n ctx.store.clickSelectedOption();\n } else if (targetType === 'button') {\n event.preventDefault();\n ctx.store.openDropdown('keyboard');\n }\n }\n\n if (event.nativeEvent.code === 'Escape') {\n ctx.store.closeDropdown('keyboard');\n }\n\n if (event.nativeEvent.code === 'Space') {\n if (targetType === 'button') {\n event.preventDefault();\n ctx.store.toggleDropdown('keyboard');\n }\n }\n }\n };\n\n const ariaAttributes = withAriaAttributes\n ? {\n 'aria-haspopup': 'listbox',\n 'aria-expanded'
|
|
1
|
+
{"version":3,"file":"use-combobox-target-props.js","sources":["../../../../src/components/Combobox/use-combobox-target-props/use-combobox-target-props.ts"],"sourcesContent":["import { useState } from 'react';\nimport { useComboboxContext } from '../Combobox.context';\n\ninterface UseComboboxTargetPropsInput {\n targetType: 'input' | 'button' | undefined;\n withAriaAttributes: boolean | undefined;\n withKeyboardNavigation: boolean | undefined;\n withExpandedAttribute: boolean | undefined;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement> | undefined;\n}\n\nexport function useComboboxTargetProps({\n onKeyDown,\n withKeyboardNavigation,\n withAriaAttributes,\n withExpandedAttribute,\n targetType,\n}: UseComboboxTargetPropsInput) {\n const ctx = useComboboxContext();\n const [selectedOptionId, setSelectedOptionId] = useState<string | null>(null);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (ctx.readOnly) {\n return;\n }\n\n if (withKeyboardNavigation) {\n if (event.nativeEvent.code === 'ArrowDown') {\n event.preventDefault();\n\n if (!ctx.store.dropdownOpened) {\n ctx.store.openDropdown('keyboard');\n setSelectedOptionId(ctx.store.selectActiveOption());\n } else {\n setSelectedOptionId(ctx.store.selectNextOption());\n }\n }\n\n if (event.nativeEvent.code === 'ArrowUp') {\n event.preventDefault();\n\n if (!ctx.store.dropdownOpened) {\n ctx.store.openDropdown('keyboard');\n setSelectedOptionId(ctx.store.selectActiveOption());\n } else {\n setSelectedOptionId(ctx.store.selectPreviousOption());\n }\n }\n\n if (event.nativeEvent.code === 'Enter') {\n if (ctx.store.dropdownOpened) {\n event.preventDefault();\n ctx.store.clickSelectedOption();\n } else if (targetType === 'button') {\n event.preventDefault();\n ctx.store.openDropdown('keyboard');\n }\n }\n\n if (event.nativeEvent.code === 'Escape') {\n ctx.store.closeDropdown('keyboard');\n }\n\n if (event.nativeEvent.code === 'Space') {\n if (targetType === 'button') {\n event.preventDefault();\n ctx.store.toggleDropdown('keyboard');\n }\n }\n }\n };\n\n const ariaAttributes = withAriaAttributes\n ? {\n 'aria-haspopup': 'listbox',\n 'aria-expanded':\n (withExpandedAttribute && !!(ctx.store.listId && ctx.store.dropdownOpened)) || undefined,\n 'aria-controls': ctx.store.listId,\n 'aria-activedescendant': ctx.store.dropdownOpened\n ? selectedOptionId || undefined\n : undefined,\n autoComplete: 'off',\n 'data-expanded': ctx.store.dropdownOpened ? true : undefined,\n }\n : {};\n\n return {\n ...ariaAttributes,\n onKeyDown: handleKeyDown,\n };\n}\n"],"names":["useComboboxContext","useState"],"mappings":";;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAA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AAG,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,GAAG,KAAK,CAAC;AAC7D,GAAG,GAAG,EAAE,CAAC;AACT,EAAE,OAAO,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,cAAc,CAAC,EAAE;AAC3D,IAAI,SAAS,EAAE,aAAa;AAC5B,GAAG,CAAC,CAAC;AACL;;;;"}
|
|
@@ -41,7 +41,8 @@ function GridColVariables({ span, order, offset, selector }) {
|
|
|
41
41
|
var _a;
|
|
42
42
|
const theme = MantineThemeProvider.useMantineTheme();
|
|
43
43
|
const ctx = Grid_context.useGridContext();
|
|
44
|
-
const
|
|
44
|
+
const baseValue = getBaseValue.getBaseValue(span);
|
|
45
|
+
const baseSpan = baseValue === void 0 ? 12 : getBaseValue.getBaseValue(span);
|
|
45
46
|
const baseStyles = filterProps.filterProps({
|
|
46
47
|
"--col-order": (_a = getBaseValue.getBaseValue(order)) == null ? void 0 : _a.toString(),
|
|
47
48
|
"--col-flex-grow": getColumnFlexGrow(baseSpan, ctx.grow),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridColVariables.js","sources":["../../../../src/components/Grid/GridCol/GridColVariables.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getSortedBreakpoints,\n useMantineTheme,\n keys,\n MantineBreakpoint,\n filterProps,\n InlineStyles,\n getBaseValue,\n} from '../../../core';\nimport type { GridColProps, ColSpan } from './GridCol';\nimport { useGridContext } from '../Grid.context';\n\ninterface GridColVariablesProps {\n selector: string;\n span: GridColProps['span'] | undefined;\n order?: GridColProps['order'] | undefined;\n offset?: GridColProps['offset'] | undefined;\n}\n\nconst getColumnFlexBasis = (colSpan: ColSpan | undefined, columns: number) => {\n if (colSpan === 'content') {\n return 'auto';\n }\n\n if (colSpan === 'auto') {\n return '0rem';\n }\n\n return colSpan ? `${100 / (columns / colSpan)}%` : undefined;\n};\n\nconst getColumnMaxWidth = (\n colSpan: ColSpan | undefined,\n columns: number,\n grow: boolean | undefined\n) => {\n if (grow || colSpan === 'auto' || colSpan === 'content') {\n return 'unset';\n }\n\n return getColumnFlexBasis(colSpan, columns);\n};\n\nconst getColumnFlexGrow = (colSpan: ColSpan | undefined, grow: boolean | undefined) => {\n if (!colSpan) {\n return undefined;\n }\n\n return colSpan === 'auto' || grow ? '1' : undefined;\n};\n\nconst getColumnOffset = (offset: number | undefined, columns: number) =>\n offset === 0 ? '0' : offset ? `${100 / (columns / offset)}%` : undefined;\n\nexport function GridColVariables({ span, order, offset, selector }: GridColVariablesProps) {\n const theme = useMantineTheme();\n const ctx = useGridContext();\n\n const baseSpan = getBaseValue(span);\n\n const baseStyles: Record<string, string | undefined> = filterProps({\n '--col-order': getBaseValue(order)?.toString(),\n '--col-flex-grow': getColumnFlexGrow(baseSpan, ctx.grow),\n '--col-flex-basis': getColumnFlexBasis(baseSpan, ctx.columns),\n '--col-width': baseSpan === 'content' ? 'auto' : undefined,\n '--col-max-width': getColumnMaxWidth(baseSpan, ctx.columns, ctx.grow),\n '--col-offset': getColumnOffset(getBaseValue(offset), ctx.columns),\n });\n\n const queries = keys(theme.breakpoints).reduce<Record<string, Record<string, any>>>(\n (acc, breakpoint) => {\n if (!acc[breakpoint]) {\n acc[breakpoint] = {};\n }\n\n if (typeof order === 'object' && order[breakpoint] !== undefined) {\n acc[breakpoint]['--col-order'] = order[breakpoint]?.toString();\n }\n\n if (typeof span === 'object' && span[breakpoint] !== undefined) {\n acc[breakpoint]['--col-flex-grow'] = getColumnFlexGrow(span[breakpoint], ctx.grow);\n acc[breakpoint]['--col-flex-basis'] = getColumnFlexBasis(span[breakpoint], ctx.columns);\n acc[breakpoint]['--col-width'] = span[breakpoint] === 'content' ? 'auto' : undefined;\n acc[breakpoint]['--col-max-width'] = getColumnMaxWidth(\n span[breakpoint],\n ctx.columns,\n ctx.grow\n );\n }\n\n if (typeof offset === 'object' && offset[breakpoint] !== undefined) {\n acc[breakpoint]['--col-offset'] = getColumnOffset(offset[breakpoint], ctx.columns);\n }\n\n return acc;\n },\n {}\n );\n\n const sortedBreakpoints = getSortedBreakpoints(keys(queries), theme).filter(\n (breakpoint) => keys(queries[breakpoint.value]).length > 0\n );\n\n const media = sortedBreakpoints.map((breakpoint) => ({\n query: `(min-width: ${theme.breakpoints[breakpoint.value as MantineBreakpoint]})`,\n styles: queries[breakpoint.value],\n }));\n\n return <InlineStyles styles={baseStyles} media={media} selector={selector} />;\n}\n"],"names":["useMantineTheme","useGridContext","getBaseValue","filterProps","keys","getSortedBreakpoints","React","InlineStyles"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK;AACjD,EAAE,IAAI,OAAO,KAAK,SAAS,EAAE;AAC7B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,IAAI,OAAO,KAAK,MAAM,EAAE;AAC1B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,OAAO,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAC5D,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,KAAK;AACtD,EAAE,IAAI,IAAI,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,SAAS,EAAE;AAC3D,IAAI,OAAO,OAAO,CAAC;AACnB,GAAG;AACH,EAAE,OAAO,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK;AAC7C,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,OAAO,KAAK,CAAC,CAAC;AAClB,GAAG;AACH,EAAE,OAAO,OAAO,KAAK,MAAM,IAAI,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC;AACF,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAC5G,SAAS,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;AACpE,EAAE,IAAI,EAAE,CAAC;AACT,EAAE,MAAM,KAAK,GAAGA,oCAAe,EAAE,CAAC;AAClC,EAAE,MAAM,GAAG,GAAGC,2BAAc,EAAE,CAAC;AAC/B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"GridColVariables.js","sources":["../../../../src/components/Grid/GridCol/GridColVariables.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getSortedBreakpoints,\n useMantineTheme,\n keys,\n MantineBreakpoint,\n filterProps,\n InlineStyles,\n getBaseValue,\n} from '../../../core';\nimport type { GridColProps, ColSpan } from './GridCol';\nimport { useGridContext } from '../Grid.context';\n\ninterface GridColVariablesProps {\n selector: string;\n span: GridColProps['span'] | undefined;\n order?: GridColProps['order'] | undefined;\n offset?: GridColProps['offset'] | undefined;\n}\n\nconst getColumnFlexBasis = (colSpan: ColSpan | undefined, columns: number) => {\n if (colSpan === 'content') {\n return 'auto';\n }\n\n if (colSpan === 'auto') {\n return '0rem';\n }\n\n return colSpan ? `${100 / (columns / colSpan)}%` : undefined;\n};\n\nconst getColumnMaxWidth = (\n colSpan: ColSpan | undefined,\n columns: number,\n grow: boolean | undefined\n) => {\n if (grow || colSpan === 'auto' || colSpan === 'content') {\n return 'unset';\n }\n\n return getColumnFlexBasis(colSpan, columns);\n};\n\nconst getColumnFlexGrow = (colSpan: ColSpan | undefined, grow: boolean | undefined) => {\n if (!colSpan) {\n return undefined;\n }\n\n return colSpan === 'auto' || grow ? '1' : undefined;\n};\n\nconst getColumnOffset = (offset: number | undefined, columns: number) =>\n offset === 0 ? '0' : offset ? `${100 / (columns / offset)}%` : undefined;\n\nexport function GridColVariables({ span, order, offset, selector }: GridColVariablesProps) {\n const theme = useMantineTheme();\n const ctx = useGridContext();\n\n const baseValue = getBaseValue(span);\n const baseSpan = baseValue === undefined ? 12 : getBaseValue(span);\n\n const baseStyles: Record<string, string | undefined> = filterProps({\n '--col-order': getBaseValue(order)?.toString(),\n '--col-flex-grow': getColumnFlexGrow(baseSpan, ctx.grow),\n '--col-flex-basis': getColumnFlexBasis(baseSpan, ctx.columns),\n '--col-width': baseSpan === 'content' ? 'auto' : undefined,\n '--col-max-width': getColumnMaxWidth(baseSpan, ctx.columns, ctx.grow),\n '--col-offset': getColumnOffset(getBaseValue(offset), ctx.columns),\n });\n\n const queries = keys(theme.breakpoints).reduce<Record<string, Record<string, any>>>(\n (acc, breakpoint) => {\n if (!acc[breakpoint]) {\n acc[breakpoint] = {};\n }\n\n if (typeof order === 'object' && order[breakpoint] !== undefined) {\n acc[breakpoint]['--col-order'] = order[breakpoint]?.toString();\n }\n\n if (typeof span === 'object' && span[breakpoint] !== undefined) {\n acc[breakpoint]['--col-flex-grow'] = getColumnFlexGrow(span[breakpoint], ctx.grow);\n acc[breakpoint]['--col-flex-basis'] = getColumnFlexBasis(span[breakpoint], ctx.columns);\n acc[breakpoint]['--col-width'] = span[breakpoint] === 'content' ? 'auto' : undefined;\n acc[breakpoint]['--col-max-width'] = getColumnMaxWidth(\n span[breakpoint],\n ctx.columns,\n ctx.grow\n );\n }\n\n if (typeof offset === 'object' && offset[breakpoint] !== undefined) {\n acc[breakpoint]['--col-offset'] = getColumnOffset(offset[breakpoint], ctx.columns);\n }\n\n return acc;\n },\n {}\n );\n\n const sortedBreakpoints = getSortedBreakpoints(keys(queries), theme).filter(\n (breakpoint) => keys(queries[breakpoint.value]).length > 0\n );\n\n const media = sortedBreakpoints.map((breakpoint) => ({\n query: `(min-width: ${theme.breakpoints[breakpoint.value as MantineBreakpoint]})`,\n styles: queries[breakpoint.value],\n }));\n\n return <InlineStyles styles={baseStyles} media={media} selector={selector} />;\n}\n"],"names":["useMantineTheme","useGridContext","getBaseValue","filterProps","keys","getSortedBreakpoints","React","InlineStyles"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK;AACjD,EAAE,IAAI,OAAO,KAAK,SAAS,EAAE;AAC7B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,IAAI,OAAO,KAAK,MAAM,EAAE;AAC1B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,OAAO,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAC5D,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,KAAK;AACtD,EAAE,IAAI,IAAI,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,SAAS,EAAE;AAC3D,IAAI,OAAO,OAAO,CAAC;AACnB,GAAG;AACH,EAAE,OAAO,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK;AAC7C,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,OAAO,KAAK,CAAC,CAAC;AAClB,GAAG;AACH,EAAE,OAAO,OAAO,KAAK,MAAM,IAAI,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC;AACF,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAC5G,SAAS,gBA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CAAC,OAAO,CAAC,CAAC;AAC3F,OAAO;AACP,MAAM,OAAO,GAAG,CAAC;AACjB,KAAK;AACL,IAAI,EAAE;AACN,GAAG,CAAC;AACJ,EAAE,MAAM,iBAAiB,GAAGC,yCAAoB,CAACD,SAAI,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM;AAC7E,IAAI,CAAC,UAAU,KAAKA,SAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;AAC9D,GAAG,CAAC;AACJ,EAAE,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,MAAM;AACvD,IAAI,KAAK,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChE,IAAI,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;AACrC,GAAG,CAAC,CAAC,CAAC;AACN,EAAE,uBAAuBE,cAAK,CAAC,aAAa,CAACC,yBAAY,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AACpG;;;;"}
|
|
@@ -121,7 +121,8 @@ const MultiSelect = factory.factory((_props, ref) => {
|
|
|
121
121
|
hidePickedOptions,
|
|
122
122
|
withErrorStyles,
|
|
123
123
|
name,
|
|
124
|
-
form
|
|
124
|
+
form,
|
|
125
|
+
id
|
|
125
126
|
} = _a, others = __objRest(_a, [
|
|
126
127
|
"classNames",
|
|
127
128
|
"className",
|
|
@@ -182,8 +183,10 @@ const MultiSelect = factory.factory((_props, ref) => {
|
|
|
182
183
|
"hidePickedOptions",
|
|
183
184
|
"withErrorStyles",
|
|
184
185
|
"name",
|
|
185
|
-
"form"
|
|
186
|
+
"form",
|
|
187
|
+
"id"
|
|
186
188
|
]);
|
|
189
|
+
const _id = hooks.useId(id);
|
|
187
190
|
const parsedData = getParsedComboboxData.getParsedComboboxData(data);
|
|
188
191
|
const optionsLockup = getOptionsLockup.getOptionsLockup(parsedData);
|
|
189
192
|
const combobox = useCombobox.useCombobox({
|
|
@@ -299,12 +302,14 @@ const MultiSelect = factory.factory((_props, ref) => {
|
|
|
299
302
|
withErrorStyles,
|
|
300
303
|
__stylesApiProps: __spreadProps(__spreadValues({}, props), { multiline: true }),
|
|
301
304
|
pointer: !searchable,
|
|
302
|
-
onClick: () => searchable ? combobox.openDropdown() : combobox.toggleDropdown()
|
|
305
|
+
onClick: () => searchable ? combobox.openDropdown() : combobox.toggleDropdown(),
|
|
306
|
+
id: _id
|
|
303
307
|
}),
|
|
304
308
|
/* @__PURE__ */ React__default.createElement(Pill.Pill.Group, __spreadValues({ disabled, unstyled }, getStyles("pillsList")), values, /* @__PURE__ */ React__default.createElement(Combobox.Combobox.EventsTarget, null, /* @__PURE__ */ React__default.createElement(
|
|
305
309
|
PillsInput.PillsInput.Field,
|
|
306
310
|
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
307
|
-
ref
|
|
311
|
+
ref,
|
|
312
|
+
id: _id
|
|
308
313
|
}), getStyles("inputField")), {
|
|
309
314
|
unstyled,
|
|
310
315
|
onFocus: (event) => {
|
|
@@ -345,7 +350,8 @@ const MultiSelect = factory.factory((_props, ref) => {
|
|
|
345
350
|
checkIconPosition,
|
|
346
351
|
withCheckIcon,
|
|
347
352
|
nothingFoundMessage,
|
|
348
|
-
unstyled
|
|
353
|
+
unstyled,
|
|
354
|
+
labelId: `${_id}-label`
|
|
349
355
|
}
|
|
350
356
|
)
|
|
351
357
|
), /* @__PURE__ */ React__default.createElement("input", { type: "hidden", name, value: _value.join(","), form, disabled }));
|