@fairmint/ui 0.4.2 → 0.4.3
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/dist/_virtual/index3.cjs +5 -3
- package/dist/_virtual/index3.cjs.map +1 -1
- package/dist/_virtual/index3.js +5 -2
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/_virtual/index4.cjs +3 -5
- package/dist/_virtual/index4.cjs.map +1 -1
- package/dist/_virtual/index4.js +2 -5
- package/dist/_virtual/index4.js.map +1 -1
- package/dist/components/primitives/MultiSelect/MultiSelect.cjs +6 -1
- package/dist/components/primitives/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/primitives/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/primitives/MultiSelect/MultiSelect.js +6 -1
- package/dist/components/primitives/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/primitives/Select/Select.cjs +8 -2
- package/dist/components/primitives/Select/Select.cjs.map +1 -1
- package/dist/components/primitives/Select/Select.d.ts.map +1 -1
- package/dist/components/primitives/Select/Select.js +8 -2
- package/dist/components/primitives/Select/Select.js.map +1 -1
- package/dist/components/primitives/muiCompat.cjs +6 -0
- package/dist/components/primitives/muiCompat.cjs.map +1 -1
- package/dist/components/primitives/muiCompat.d.ts.map +1 -1
- package/dist/components/primitives/muiCompat.js +6 -0
- package/dist/components/primitives/muiCompat.js.map +1 -1
- package/dist/node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.cjs +1 -1
- package/dist/node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.js +1 -1
- package/dist/node_modules/prop-types/index.cjs +1 -1
- package/dist/node_modules/prop-types/index.js +1 -1
- package/dist/theme/index.cjs +13 -0
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +14 -0
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/zIndex.cjs +2 -0
- package/dist/theme/zIndex.cjs.map +1 -1
- package/dist/theme/zIndex.d.ts +5 -0
- package/dist/theme/zIndex.d.ts.map +1 -1
- package/dist/theme/zIndex.js +2 -0
- package/dist/theme/zIndex.js.map +1 -1
- package/package.json +1 -1
package/dist/_virtual/index3.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const _commonjsHelpers = require("./_commonjsHelpers.cjs");
|
|
3
|
+
const index = require("../node_modules/fast-deep-equal/index.cjs");
|
|
4
|
+
var fastDeepEqualExports = index.__require();
|
|
5
|
+
const isEqual = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(fastDeepEqualExports);
|
|
6
|
+
module.exports = isEqual;
|
|
5
7
|
//# sourceMappingURL=index3.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { getDefaultExportFromCjs } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as requireFastDeepEqual } from "../node_modules/fast-deep-equal/index.js";
|
|
3
|
+
var fastDeepEqualExports = requireFastDeepEqual();
|
|
4
|
+
const isEqual = /* @__PURE__ */ getDefaultExportFromCjs(fastDeepEqualExports);
|
|
2
5
|
export {
|
|
3
|
-
|
|
6
|
+
isEqual as default
|
|
4
7
|
};
|
|
5
8
|
//# sourceMappingURL=index3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/_virtual/index4.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const isEqual = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(fastDeepEqualExports);
|
|
6
|
-
module.exports = isEqual;
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var propTypes = { exports: {} };
|
|
4
|
+
exports.__module = propTypes;
|
|
7
5
|
//# sourceMappingURL=index4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index4.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index4.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/_virtual/index4.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { __require as requireFastDeepEqual } from "../node_modules/fast-deep-equal/index.js";
|
|
3
|
-
var fastDeepEqualExports = requireFastDeepEqual();
|
|
4
|
-
const isEqual = /* @__PURE__ */ getDefaultExportFromCjs(fastDeepEqualExports);
|
|
1
|
+
var propTypes = { exports: {} };
|
|
5
2
|
export {
|
|
6
|
-
|
|
3
|
+
propTypes as __module
|
|
7
4
|
};
|
|
8
5
|
//# sourceMappingURL=index4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
+
const zIndex = require("../../../theme/zIndex.cjs");
|
|
5
6
|
const MultiSelect$1 = require("../../../node_modules/@mantine/core/esm/components/MultiSelect/MultiSelect.cjs");
|
|
6
7
|
const horizontalPillsListClassName = "fairmint-multiselect-pills-list";
|
|
7
8
|
function mergeClassName(...classes) {
|
|
@@ -23,11 +24,15 @@ function appendHorizontalPillsListClass(classNames) {
|
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
const MultiSelect = React.forwardRef(
|
|
26
|
-
({ classNames, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
({ classNames, comboboxProps, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
28
|
MultiSelect$1.MultiSelect,
|
|
28
29
|
{
|
|
29
30
|
size: "md",
|
|
30
31
|
classNames: appendHorizontalPillsListClass(classNames),
|
|
32
|
+
comboboxProps: {
|
|
33
|
+
zIndex: zIndex.overlayZIndexAboveFairmintOverlays,
|
|
34
|
+
...comboboxProps
|
|
35
|
+
},
|
|
31
36
|
...props,
|
|
32
37
|
ref
|
|
33
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.cjs","sources":["../../../../src/components/primitives/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import {\n MultiSelect as MantineMultiSelect,\n type MultiSelectProps as MantineMultiSelectProps,\n} from \"@mantine/core\";\nimport { forwardRef } from \"react\";\n\nexport interface MultiSelectProps extends MantineMultiSelectProps {}\n\nconst horizontalPillsListClassName = \"fairmint-multiselect-pills-list\";\n\nfunction mergeClassName(...classes: Array<string | undefined>): string | undefined {\n return classes.filter(Boolean).join(\" \") || undefined;\n}\n\nfunction appendHorizontalPillsListClass(\n classNames: MantineMultiSelectProps[\"classNames\"],\n): MantineMultiSelectProps[\"classNames\"] {\n if (typeof classNames === \"function\") {\n return (theme, props, ctx) => {\n const resolvedClassNames = classNames(theme, props, ctx);\n return {\n ...resolvedClassNames,\n pillsList: mergeClassName(horizontalPillsListClassName, resolvedClassNames?.pillsList),\n };\n };\n }\n\n return {\n ...classNames,\n pillsList: mergeClassName(horizontalPillsListClassName, classNames?.pillsList),\n };\n}\n\nexport const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(\n ({ classNames, ...props }, ref) => (\n <MantineMultiSelect\n size=\"md\"\n classNames={appendHorizontalPillsListClass(classNames)}\n {...props}\n ref={ref}\n />\n ),\n);\nMultiSelect.displayName = \"MultiSelect\";\n"],"names":["forwardRef","jsx","MantineMultiSelect"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiSelect.cjs","sources":["../../../../src/components/primitives/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import {\n MultiSelect as MantineMultiSelect,\n type MultiSelectProps as MantineMultiSelectProps,\n} from \"@mantine/core\";\nimport { forwardRef } from \"react\";\nimport { overlayZIndexAboveFairmintOverlays } from \"../../../theme/zIndex\";\n\nexport interface MultiSelectProps extends MantineMultiSelectProps {}\n\nconst horizontalPillsListClassName = \"fairmint-multiselect-pills-list\";\n\nfunction mergeClassName(...classes: Array<string | undefined>): string | undefined {\n return classes.filter(Boolean).join(\" \") || undefined;\n}\n\nfunction appendHorizontalPillsListClass(\n classNames: MantineMultiSelectProps[\"classNames\"],\n): MantineMultiSelectProps[\"classNames\"] {\n if (typeof classNames === \"function\") {\n return (theme, props, ctx) => {\n const resolvedClassNames = classNames(theme, props, ctx);\n return {\n ...resolvedClassNames,\n pillsList: mergeClassName(horizontalPillsListClassName, resolvedClassNames?.pillsList),\n };\n };\n }\n\n return {\n ...classNames,\n pillsList: mergeClassName(horizontalPillsListClassName, classNames?.pillsList),\n };\n}\n\nexport const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(\n ({ classNames, comboboxProps, ...props }, ref) => (\n <MantineMultiSelect\n size=\"md\"\n classNames={appendHorizontalPillsListClass(classNames)}\n comboboxProps={{\n zIndex: overlayZIndexAboveFairmintOverlays,\n ...comboboxProps,\n }}\n {...props}\n ref={ref}\n />\n ),\n);\nMultiSelect.displayName = \"MultiSelect\";\n"],"names":["forwardRef","jsx","MantineMultiSelect","overlayZIndexAboveFairmintOverlays"],"mappings":";;;;;;AASA,MAAM,+BAA+B;AAErC,SAAS,kBAAkB,SAAwD;AACjF,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,KAAK;AAC9C;AAEA,SAAS,+BACP,YACuC;AACvC,MAAI,OAAO,eAAe,YAAY;AACpC,WAAO,CAAC,OAAO,OAAO,QAAQ;AAC5B,YAAM,qBAAqB,WAAW,OAAO,OAAO,GAAG;AACvD,aAAO;AAAA,QACL,GAAG;AAAA,QACH,WAAW,eAAe,8BAA8B,oBAAoB,SAAS;AAAA,MAAA;AAAA,IAEzF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,WAAW,eAAe,8BAA8B,YAAY,SAAS;AAAA,EAAA;AAEjF;AAEO,MAAM,cAAcA,MAAAA;AAAAA,EACzB,CAAC,EAAE,YAAY,eAAe,GAAG,MAAA,GAAS,QACxCC,2BAAAA;AAAAA,IAACC,cAAAA;AAAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,YAAY,+BAA+B,UAAU;AAAA,MACrD,eAAe;AAAA,QACb,QAAQC,OAAAA;AAAAA,QACR,GAAG;AAAA,MAAA;AAAA,MAEJ,GAAG;AAAA,MACJ;AAAA,IAAA;AAAA,EAAA;AAGN;AACA,YAAY,cAAc;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/MultiSelect/MultiSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,IAAI,uBAAuB,EACjD,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/MultiSelect/MultiSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,IAAI,uBAAuB,EACjD,MAAM,eAAe,CAAC;AAIvB,MAAM,WAAW,gBAAiB,SAAQ,uBAAuB;CAAG;AA2BpE,eAAO,MAAM,WAAW,+GAavB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
+
import { overlayZIndexAboveFairmintOverlays } from "../../../theme/zIndex.js";
|
|
3
4
|
import { MultiSelect as MultiSelect$1 } from "../../../node_modules/@mantine/core/esm/components/MultiSelect/MultiSelect.js";
|
|
4
5
|
const horizontalPillsListClassName = "fairmint-multiselect-pills-list";
|
|
5
6
|
function mergeClassName(...classes) {
|
|
@@ -21,11 +22,15 @@ function appendHorizontalPillsListClass(classNames) {
|
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
const MultiSelect = forwardRef(
|
|
24
|
-
({ classNames, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
25
|
+
({ classNames, comboboxProps, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
25
26
|
MultiSelect$1,
|
|
26
27
|
{
|
|
27
28
|
size: "md",
|
|
28
29
|
classNames: appendHorizontalPillsListClass(classNames),
|
|
30
|
+
comboboxProps: {
|
|
31
|
+
zIndex: overlayZIndexAboveFairmintOverlays,
|
|
32
|
+
...comboboxProps
|
|
33
|
+
},
|
|
29
34
|
...props,
|
|
30
35
|
ref
|
|
31
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.js","sources":["../../../../src/components/primitives/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import {\n MultiSelect as MantineMultiSelect,\n type MultiSelectProps as MantineMultiSelectProps,\n} from \"@mantine/core\";\nimport { forwardRef } from \"react\";\n\nexport interface MultiSelectProps extends MantineMultiSelectProps {}\n\nconst horizontalPillsListClassName = \"fairmint-multiselect-pills-list\";\n\nfunction mergeClassName(...classes: Array<string | undefined>): string | undefined {\n return classes.filter(Boolean).join(\" \") || undefined;\n}\n\nfunction appendHorizontalPillsListClass(\n classNames: MantineMultiSelectProps[\"classNames\"],\n): MantineMultiSelectProps[\"classNames\"] {\n if (typeof classNames === \"function\") {\n return (theme, props, ctx) => {\n const resolvedClassNames = classNames(theme, props, ctx);\n return {\n ...resolvedClassNames,\n pillsList: mergeClassName(horizontalPillsListClassName, resolvedClassNames?.pillsList),\n };\n };\n }\n\n return {\n ...classNames,\n pillsList: mergeClassName(horizontalPillsListClassName, classNames?.pillsList),\n };\n}\n\nexport const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(\n ({ classNames, ...props }, ref) => (\n <MantineMultiSelect\n size=\"md\"\n classNames={appendHorizontalPillsListClass(classNames)}\n {...props}\n ref={ref}\n />\n ),\n);\nMultiSelect.displayName = \"MultiSelect\";\n"],"names":["MantineMultiSelect"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiSelect.js","sources":["../../../../src/components/primitives/MultiSelect/MultiSelect.tsx"],"sourcesContent":["import {\n MultiSelect as MantineMultiSelect,\n type MultiSelectProps as MantineMultiSelectProps,\n} from \"@mantine/core\";\nimport { forwardRef } from \"react\";\nimport { overlayZIndexAboveFairmintOverlays } from \"../../../theme/zIndex\";\n\nexport interface MultiSelectProps extends MantineMultiSelectProps {}\n\nconst horizontalPillsListClassName = \"fairmint-multiselect-pills-list\";\n\nfunction mergeClassName(...classes: Array<string | undefined>): string | undefined {\n return classes.filter(Boolean).join(\" \") || undefined;\n}\n\nfunction appendHorizontalPillsListClass(\n classNames: MantineMultiSelectProps[\"classNames\"],\n): MantineMultiSelectProps[\"classNames\"] {\n if (typeof classNames === \"function\") {\n return (theme, props, ctx) => {\n const resolvedClassNames = classNames(theme, props, ctx);\n return {\n ...resolvedClassNames,\n pillsList: mergeClassName(horizontalPillsListClassName, resolvedClassNames?.pillsList),\n };\n };\n }\n\n return {\n ...classNames,\n pillsList: mergeClassName(horizontalPillsListClassName, classNames?.pillsList),\n };\n}\n\nexport const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(\n ({ classNames, comboboxProps, ...props }, ref) => (\n <MantineMultiSelect\n size=\"md\"\n classNames={appendHorizontalPillsListClass(classNames)}\n comboboxProps={{\n zIndex: overlayZIndexAboveFairmintOverlays,\n ...comboboxProps,\n }}\n {...props}\n ref={ref}\n />\n ),\n);\nMultiSelect.displayName = \"MultiSelect\";\n"],"names":["MantineMultiSelect"],"mappings":";;;;AASA,MAAM,+BAA+B;AAErC,SAAS,kBAAkB,SAAwD;AACjF,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,KAAK;AAC9C;AAEA,SAAS,+BACP,YACuC;AACvC,MAAI,OAAO,eAAe,YAAY;AACpC,WAAO,CAAC,OAAO,OAAO,QAAQ;AAC5B,YAAM,qBAAqB,WAAW,OAAO,OAAO,GAAG;AACvD,aAAO;AAAA,QACL,GAAG;AAAA,QACH,WAAW,eAAe,8BAA8B,oBAAoB,SAAS;AAAA,MAAA;AAAA,IAEzF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,WAAW,eAAe,8BAA8B,YAAY,SAAS;AAAA,EAAA;AAEjF;AAEO,MAAM,cAAc;AAAA,EACzB,CAAC,EAAE,YAAY,eAAe,GAAG,MAAA,GAAS,QACxC;AAAA,IAACA;AAAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,YAAY,+BAA+B,UAAU;AAAA,MACrD,eAAe;AAAA,QACb,QAAQ;AAAA,QACR,GAAG;AAAA,MAAA;AAAA,MAEJ,GAAG;AAAA,MACJ;AAAA,IAAA;AAAA,EAAA;AAGN;AACA,YAAY,cAAc;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
+
const zIndex = require("../../../theme/zIndex.cjs");
|
|
5
6
|
const Select$1 = require("../../../node_modules/@mantine/core/esm/components/Select/Select.cjs");
|
|
6
7
|
const nodeToLabel = (node) => {
|
|
7
8
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
@@ -66,13 +67,18 @@ const Select = React.forwardRef(
|
|
|
66
67
|
const rendersOwnHiddenInput = Boolean(children && name);
|
|
67
68
|
const selectedOriginalValue = value === void 0 ? uncontrolledOriginalValue : resolveOriginalValue(resolveInternalValue(value));
|
|
68
69
|
const hiddenValue = selectedOriginalValue == null ? "" : String(selectedOriginalValue);
|
|
70
|
+
const mergedComboboxProps = {
|
|
71
|
+
zIndex: zIndex.overlayZIndexAboveFairmintOverlays,
|
|
72
|
+
...comboboxProps
|
|
73
|
+
};
|
|
69
74
|
if (!children && !endAdornment) {
|
|
70
|
-
const { onChange: mantineOnChange, ...mantineProps } = props;
|
|
75
|
+
const { comboboxProps: _comboboxProps, onChange: mantineOnChange, ...mantineProps } = props;
|
|
71
76
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
77
|
Select$1.Select,
|
|
73
78
|
{
|
|
74
79
|
size: "md",
|
|
75
80
|
...mantineProps,
|
|
81
|
+
comboboxProps: mergedComboboxProps,
|
|
76
82
|
onChange: mantineOnChange,
|
|
77
83
|
ref
|
|
78
84
|
}
|
|
@@ -93,7 +99,7 @@ const Select = React.forwardRef(
|
|
|
93
99
|
hiddenInputProps: rendersOwnHiddenInput ? void 0 : hiddenInputProps,
|
|
94
100
|
name: rendersOwnHiddenInput ? void 0 : name,
|
|
95
101
|
value: value === void 0 ? void 0 : value == null ? null : String(resolveInternalValue(value)),
|
|
96
|
-
comboboxProps,
|
|
102
|
+
comboboxProps: mergedComboboxProps,
|
|
97
103
|
rightSection: rightSection || endAdornment,
|
|
98
104
|
styles,
|
|
99
105
|
onChange: (next, option) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs","sources":["../../../../src/components/primitives/Select/Select.tsx"],"sourcesContent":["import { Select as MantineSelect, type SelectProps as MantineSelectProps } from \"@mantine/core\";\nimport {\n Children,\n forwardRef,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useState,\n} from \"react\";\n\ntype SelectChangeEvent = {\n currentTarget: { name?: string; value: unknown };\n target: { name?: string; value: unknown };\n};\n\ntype LegacySelectChange = (event: SelectChangeEvent, option: unknown) => void;\n\nexport interface SelectProps extends Omit<MantineSelectProps, \"onChange\"> {\n children?: ReactNode;\n endAdornment?: ReactNode;\n onChange?: MantineSelectProps[\"onChange\"] | LegacySelectChange;\n}\n\ntype SelectChildProps = {\n children?: ReactNode;\n value?: unknown;\n};\n\nconst nodeToLabel = (node: ReactNode): string => {\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(nodeToLabel).join(\"\");\n if (isValidElement<SelectChildProps>(node)) return nodeToLabel(node.props.children);\n return \"\";\n};\n\nexport const Select = forwardRef<HTMLInputElement, SelectProps>(\n ({ children, endAdornment, ...props }, ref) => {\n const {\n classNames,\n comboboxProps,\n data,\n defaultValue,\n hiddenInputProps,\n name,\n onChange,\n rightSection,\n styles,\n value,\n ...compatProps\n } = props;\n const classNameMap = typeof classNames === \"function\" ? undefined : classNames;\n const rawChildOptions = children\n ? Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const option = child as ReactElement<SelectChildProps>;\n const stringValue = String(option.props.value);\n return {\n index,\n label: nodeToLabel(option.props.children),\n originalValue: option.props.value,\n stringValue,\n };\n })\n : undefined;\n const stringValueCounts = new Map<string, number>();\n rawChildOptions?.forEach((option) => {\n stringValueCounts.set(\n option.stringValue,\n (stringValueCounts.get(option.stringValue) ?? 0) + 1,\n );\n });\n const childOptions = rawChildOptions?.map((option) => ({\n ...option,\n value:\n (stringValueCounts.get(option.stringValue) ?? 0) > 1\n ? `${option.stringValue}::${option.index}`\n : option.stringValue,\n }));\n const childValuesByInternalValue = new Map(\n childOptions?.map((option) => [option.value, option.originalValue]),\n );\n const resolveInternalValue = (nextValue: unknown) => {\n if (nextValue == null) return nextValue;\n const matchingOption = childOptions?.find((option) =>\n Object.is(option.originalValue, nextValue),\n );\n return matchingOption?.value ?? String(nextValue);\n };\n const resolveOriginalValue = (nextValue: unknown) => {\n if (nextValue == null) return null;\n return childValuesByInternalValue.has(String(nextValue))\n ? childValuesByInternalValue.get(String(nextValue))\n : nextValue;\n };\n const [uncontrolledOriginalValue, setUncontrolledOriginalValue] = useState(\n defaultValue == null ? null : resolveOriginalValue(resolveInternalValue(defaultValue)),\n );\n const rendersOwnHiddenInput = Boolean(children && name);\n const selectedOriginalValue =\n value === undefined\n ? uncontrolledOriginalValue\n : resolveOriginalValue(resolveInternalValue(value));\n const hiddenValue = selectedOriginalValue == null ? \"\" : String(selectedOriginalValue);\n\n if (!children && !endAdornment) {\n const { onChange: mantineOnChange, ...mantineProps } = props;\n return (\n <MantineSelect\n size=\"md\"\n {...mantineProps}\n onChange={mantineOnChange as MantineSelectProps[\"onChange\"]}\n ref={ref}\n />\n );\n }\n\n return (\n <>\n <MantineSelect\n size=\"md\"\n classNames={{\n ...classNameMap,\n input: [\"MuiSelect-select\", \"fairmint-select-input\", classNameMap?.input]\n .filter(Boolean)\n .join(\" \"),\n option: [\"fairmint-select-option\", classNameMap?.option].filter(Boolean).join(\" \"),\n }}\n data={children ? childOptions?.map(({ label, value }) => ({ label, value })) : data}\n defaultValue={\n defaultValue == null ? undefined : String(resolveInternalValue(defaultValue))\n }\n hiddenInputProps={rendersOwnHiddenInput ? undefined : hiddenInputProps}\n name={rendersOwnHiddenInput ? undefined : name}\n value={\n value === undefined\n ? undefined\n : value == null\n ? null\n : String(resolveInternalValue(value))\n }\n comboboxProps={
|
|
1
|
+
{"version":3,"file":"Select.cjs","sources":["../../../../src/components/primitives/Select/Select.tsx"],"sourcesContent":["import { Select as MantineSelect, type SelectProps as MantineSelectProps } from \"@mantine/core\";\nimport {\n Children,\n forwardRef,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useState,\n} from \"react\";\nimport { overlayZIndexAboveFairmintOverlays } from \"../../../theme/zIndex\";\n\ntype SelectChangeEvent = {\n currentTarget: { name?: string; value: unknown };\n target: { name?: string; value: unknown };\n};\n\ntype LegacySelectChange = (event: SelectChangeEvent, option: unknown) => void;\n\nexport interface SelectProps extends Omit<MantineSelectProps, \"onChange\"> {\n children?: ReactNode;\n endAdornment?: ReactNode;\n onChange?: MantineSelectProps[\"onChange\"] | LegacySelectChange;\n}\n\ntype SelectChildProps = {\n children?: ReactNode;\n value?: unknown;\n};\n\nconst nodeToLabel = (node: ReactNode): string => {\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(nodeToLabel).join(\"\");\n if (isValidElement<SelectChildProps>(node)) return nodeToLabel(node.props.children);\n return \"\";\n};\n\nexport const Select = forwardRef<HTMLInputElement, SelectProps>(\n ({ children, endAdornment, ...props }, ref) => {\n const {\n classNames,\n comboboxProps,\n data,\n defaultValue,\n hiddenInputProps,\n name,\n onChange,\n rightSection,\n styles,\n value,\n ...compatProps\n } = props;\n const classNameMap = typeof classNames === \"function\" ? undefined : classNames;\n const rawChildOptions = children\n ? Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const option = child as ReactElement<SelectChildProps>;\n const stringValue = String(option.props.value);\n return {\n index,\n label: nodeToLabel(option.props.children),\n originalValue: option.props.value,\n stringValue,\n };\n })\n : undefined;\n const stringValueCounts = new Map<string, number>();\n rawChildOptions?.forEach((option) => {\n stringValueCounts.set(\n option.stringValue,\n (stringValueCounts.get(option.stringValue) ?? 0) + 1,\n );\n });\n const childOptions = rawChildOptions?.map((option) => ({\n ...option,\n value:\n (stringValueCounts.get(option.stringValue) ?? 0) > 1\n ? `${option.stringValue}::${option.index}`\n : option.stringValue,\n }));\n const childValuesByInternalValue = new Map(\n childOptions?.map((option) => [option.value, option.originalValue]),\n );\n const resolveInternalValue = (nextValue: unknown) => {\n if (nextValue == null) return nextValue;\n const matchingOption = childOptions?.find((option) =>\n Object.is(option.originalValue, nextValue),\n );\n return matchingOption?.value ?? String(nextValue);\n };\n const resolveOriginalValue = (nextValue: unknown) => {\n if (nextValue == null) return null;\n return childValuesByInternalValue.has(String(nextValue))\n ? childValuesByInternalValue.get(String(nextValue))\n : nextValue;\n };\n const [uncontrolledOriginalValue, setUncontrolledOriginalValue] = useState(\n defaultValue == null ? null : resolveOriginalValue(resolveInternalValue(defaultValue)),\n );\n const rendersOwnHiddenInput = Boolean(children && name);\n const selectedOriginalValue =\n value === undefined\n ? uncontrolledOriginalValue\n : resolveOriginalValue(resolveInternalValue(value));\n const hiddenValue = selectedOriginalValue == null ? \"\" : String(selectedOriginalValue);\n const mergedComboboxProps = {\n zIndex: overlayZIndexAboveFairmintOverlays,\n ...comboboxProps,\n };\n\n if (!children && !endAdornment) {\n const { comboboxProps: _comboboxProps, onChange: mantineOnChange, ...mantineProps } = props;\n return (\n <MantineSelect\n size=\"md\"\n {...mantineProps}\n comboboxProps={mergedComboboxProps}\n onChange={mantineOnChange as MantineSelectProps[\"onChange\"]}\n ref={ref}\n />\n );\n }\n\n return (\n <>\n <MantineSelect\n size=\"md\"\n classNames={{\n ...classNameMap,\n input: [\"MuiSelect-select\", \"fairmint-select-input\", classNameMap?.input]\n .filter(Boolean)\n .join(\" \"),\n option: [\"fairmint-select-option\", classNameMap?.option].filter(Boolean).join(\" \"),\n }}\n data={children ? childOptions?.map(({ label, value }) => ({ label, value })) : data}\n defaultValue={\n defaultValue == null ? undefined : String(resolveInternalValue(defaultValue))\n }\n hiddenInputProps={rendersOwnHiddenInput ? undefined : hiddenInputProps}\n name={rendersOwnHiddenInput ? undefined : name}\n value={\n value === undefined\n ? undefined\n : value == null\n ? null\n : String(resolveInternalValue(value))\n }\n comboboxProps={mergedComboboxProps}\n rightSection={rightSection || endAdornment}\n styles={styles}\n onChange={(next, option) => {\n if (children) {\n const originalValue = resolveOriginalValue(next);\n if (value === undefined) setUncontrolledOriginalValue(originalValue);\n const event = {\n currentTarget: { name, value: originalValue },\n target: { name, value: originalValue },\n };\n (onChange as LegacySelectChange | undefined)?.(event, option);\n return;\n }\n (onChange as MantineSelectProps[\"onChange\"] | undefined)?.(next, option);\n }}\n {...compatProps}\n ref={ref}\n />\n {rendersOwnHiddenInput ? (\n <input {...hiddenInputProps} name={name} type=\"hidden\" value={hiddenValue} />\n ) : null}\n </>\n );\n },\n);\nSelect.displayName = \"Select\";\n"],"names":["isValidElement","forwardRef","Children","useState","overlayZIndexAboveFairmintOverlays","jsx","MantineSelect","jsxs","Fragment","value"],"mappings":";;;;;;AA6BA,MAAM,cAAc,CAAC,SAA4B;AAC/C,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAAU,QAAO,OAAO,IAAI;AAC5E,MAAI,MAAM,QAAQ,IAAI,EAAG,QAAO,KAAK,IAAI,WAAW,EAAE,KAAK,EAAE;AAC7D,MAAIA,MAAAA,eAAiC,IAAI,UAAU,YAAY,KAAK,MAAM,QAAQ;AAClF,SAAO;AACT;AAEO,MAAM,SAASC,MAAAA;AAAAA,EACpB,CAAC,EAAE,UAAU,cAAc,GAAG,MAAA,GAAS,QAAQ;AAC7C,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACD;AACJ,UAAM,eAAe,OAAO,eAAe,aAAa,SAAY;AACpE,UAAM,kBAAkB,WACpBC,MAAAA,SAAS,QAAQ,QAAQ,EACtB,OAAOF,MAAAA,cAAc,EACrB,IAAI,CAAC,OAAO,UAAU;AACrB,YAAM,SAAS;AACf,YAAM,cAAc,OAAO,OAAO,MAAM,KAAK;AAC7C,aAAO;AAAA,QACL;AAAA,QACA,OAAO,YAAY,OAAO,MAAM,QAAQ;AAAA,QACxC,eAAe,OAAO,MAAM;AAAA,QAC5B;AAAA,MAAA;AAAA,IAEJ,CAAC,IACH;AACJ,UAAM,wCAAwB,IAAA;AAC9B,qBAAiB,QAAQ,CAAC,WAAW;AACnC,wBAAkB;AAAA,QAChB,OAAO;AAAA,SACN,kBAAkB,IAAI,OAAO,WAAW,KAAK,KAAK;AAAA,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AAA,EAAO,GAAG,kBAAkB,MAAY,MAAK,UAAS,OAAO,YAAA,CAAa,IACzE;AAAA,IAAA,GACN;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,WAAW,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,WAAW,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAGf,KAAK,iBAAiB,GAAG;IACvB,aAAa,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IACjD,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3C,CAAC;AAEF,KAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9E,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC;IACvE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAC;CAChE;AAcD,eAAO,MAAM,MAAM,0GAwIlB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, Children, isValidElement, useState } from "react";
|
|
3
|
+
import { overlayZIndexAboveFairmintOverlays } from "../../../theme/zIndex.js";
|
|
3
4
|
import { Select as Select$1 } from "../../../node_modules/@mantine/core/esm/components/Select/Select.js";
|
|
4
5
|
const nodeToLabel = (node) => {
|
|
5
6
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
@@ -64,13 +65,18 @@ const Select = forwardRef(
|
|
|
64
65
|
const rendersOwnHiddenInput = Boolean(children && name);
|
|
65
66
|
const selectedOriginalValue = value === void 0 ? uncontrolledOriginalValue : resolveOriginalValue(resolveInternalValue(value));
|
|
66
67
|
const hiddenValue = selectedOriginalValue == null ? "" : String(selectedOriginalValue);
|
|
68
|
+
const mergedComboboxProps = {
|
|
69
|
+
zIndex: overlayZIndexAboveFairmintOverlays,
|
|
70
|
+
...comboboxProps
|
|
71
|
+
};
|
|
67
72
|
if (!children && !endAdornment) {
|
|
68
|
-
const { onChange: mantineOnChange, ...mantineProps } = props;
|
|
73
|
+
const { comboboxProps: _comboboxProps, onChange: mantineOnChange, ...mantineProps } = props;
|
|
69
74
|
return /* @__PURE__ */ jsx(
|
|
70
75
|
Select$1,
|
|
71
76
|
{
|
|
72
77
|
size: "md",
|
|
73
78
|
...mantineProps,
|
|
79
|
+
comboboxProps: mergedComboboxProps,
|
|
74
80
|
onChange: mantineOnChange,
|
|
75
81
|
ref
|
|
76
82
|
}
|
|
@@ -91,7 +97,7 @@ const Select = forwardRef(
|
|
|
91
97
|
hiddenInputProps: rendersOwnHiddenInput ? void 0 : hiddenInputProps,
|
|
92
98
|
name: rendersOwnHiddenInput ? void 0 : name,
|
|
93
99
|
value: value === void 0 ? void 0 : value == null ? null : String(resolveInternalValue(value)),
|
|
94
|
-
comboboxProps,
|
|
100
|
+
comboboxProps: mergedComboboxProps,
|
|
95
101
|
rightSection: rightSection || endAdornment,
|
|
96
102
|
styles,
|
|
97
103
|
onChange: (next, option) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../src/components/primitives/Select/Select.tsx"],"sourcesContent":["import { Select as MantineSelect, type SelectProps as MantineSelectProps } from \"@mantine/core\";\nimport {\n Children,\n forwardRef,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useState,\n} from \"react\";\n\ntype SelectChangeEvent = {\n currentTarget: { name?: string; value: unknown };\n target: { name?: string; value: unknown };\n};\n\ntype LegacySelectChange = (event: SelectChangeEvent, option: unknown) => void;\n\nexport interface SelectProps extends Omit<MantineSelectProps, \"onChange\"> {\n children?: ReactNode;\n endAdornment?: ReactNode;\n onChange?: MantineSelectProps[\"onChange\"] | LegacySelectChange;\n}\n\ntype SelectChildProps = {\n children?: ReactNode;\n value?: unknown;\n};\n\nconst nodeToLabel = (node: ReactNode): string => {\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(nodeToLabel).join(\"\");\n if (isValidElement<SelectChildProps>(node)) return nodeToLabel(node.props.children);\n return \"\";\n};\n\nexport const Select = forwardRef<HTMLInputElement, SelectProps>(\n ({ children, endAdornment, ...props }, ref) => {\n const {\n classNames,\n comboboxProps,\n data,\n defaultValue,\n hiddenInputProps,\n name,\n onChange,\n rightSection,\n styles,\n value,\n ...compatProps\n } = props;\n const classNameMap = typeof classNames === \"function\" ? undefined : classNames;\n const rawChildOptions = children\n ? Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const option = child as ReactElement<SelectChildProps>;\n const stringValue = String(option.props.value);\n return {\n index,\n label: nodeToLabel(option.props.children),\n originalValue: option.props.value,\n stringValue,\n };\n })\n : undefined;\n const stringValueCounts = new Map<string, number>();\n rawChildOptions?.forEach((option) => {\n stringValueCounts.set(\n option.stringValue,\n (stringValueCounts.get(option.stringValue) ?? 0) + 1,\n );\n });\n const childOptions = rawChildOptions?.map((option) => ({\n ...option,\n value:\n (stringValueCounts.get(option.stringValue) ?? 0) > 1\n ? `${option.stringValue}::${option.index}`\n : option.stringValue,\n }));\n const childValuesByInternalValue = new Map(\n childOptions?.map((option) => [option.value, option.originalValue]),\n );\n const resolveInternalValue = (nextValue: unknown) => {\n if (nextValue == null) return nextValue;\n const matchingOption = childOptions?.find((option) =>\n Object.is(option.originalValue, nextValue),\n );\n return matchingOption?.value ?? String(nextValue);\n };\n const resolveOriginalValue = (nextValue: unknown) => {\n if (nextValue == null) return null;\n return childValuesByInternalValue.has(String(nextValue))\n ? childValuesByInternalValue.get(String(nextValue))\n : nextValue;\n };\n const [uncontrolledOriginalValue, setUncontrolledOriginalValue] = useState(\n defaultValue == null ? null : resolveOriginalValue(resolveInternalValue(defaultValue)),\n );\n const rendersOwnHiddenInput = Boolean(children && name);\n const selectedOriginalValue =\n value === undefined\n ? uncontrolledOriginalValue\n : resolveOriginalValue(resolveInternalValue(value));\n const hiddenValue = selectedOriginalValue == null ? \"\" : String(selectedOriginalValue);\n\n if (!children && !endAdornment) {\n const { onChange: mantineOnChange, ...mantineProps } = props;\n return (\n <MantineSelect\n size=\"md\"\n {...mantineProps}\n onChange={mantineOnChange as MantineSelectProps[\"onChange\"]}\n ref={ref}\n />\n );\n }\n\n return (\n <>\n <MantineSelect\n size=\"md\"\n classNames={{\n ...classNameMap,\n input: [\"MuiSelect-select\", \"fairmint-select-input\", classNameMap?.input]\n .filter(Boolean)\n .join(\" \"),\n option: [\"fairmint-select-option\", classNameMap?.option].filter(Boolean).join(\" \"),\n }}\n data={children ? childOptions?.map(({ label, value }) => ({ label, value })) : data}\n defaultValue={\n defaultValue == null ? undefined : String(resolveInternalValue(defaultValue))\n }\n hiddenInputProps={rendersOwnHiddenInput ? undefined : hiddenInputProps}\n name={rendersOwnHiddenInput ? undefined : name}\n value={\n value === undefined\n ? undefined\n : value == null\n ? null\n : String(resolveInternalValue(value))\n }\n comboboxProps={
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../src/components/primitives/Select/Select.tsx"],"sourcesContent":["import { Select as MantineSelect, type SelectProps as MantineSelectProps } from \"@mantine/core\";\nimport {\n Children,\n forwardRef,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useState,\n} from \"react\";\nimport { overlayZIndexAboveFairmintOverlays } from \"../../../theme/zIndex\";\n\ntype SelectChangeEvent = {\n currentTarget: { name?: string; value: unknown };\n target: { name?: string; value: unknown };\n};\n\ntype LegacySelectChange = (event: SelectChangeEvent, option: unknown) => void;\n\nexport interface SelectProps extends Omit<MantineSelectProps, \"onChange\"> {\n children?: ReactNode;\n endAdornment?: ReactNode;\n onChange?: MantineSelectProps[\"onChange\"] | LegacySelectChange;\n}\n\ntype SelectChildProps = {\n children?: ReactNode;\n value?: unknown;\n};\n\nconst nodeToLabel = (node: ReactNode): string => {\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(nodeToLabel).join(\"\");\n if (isValidElement<SelectChildProps>(node)) return nodeToLabel(node.props.children);\n return \"\";\n};\n\nexport const Select = forwardRef<HTMLInputElement, SelectProps>(\n ({ children, endAdornment, ...props }, ref) => {\n const {\n classNames,\n comboboxProps,\n data,\n defaultValue,\n hiddenInputProps,\n name,\n onChange,\n rightSection,\n styles,\n value,\n ...compatProps\n } = props;\n const classNameMap = typeof classNames === \"function\" ? undefined : classNames;\n const rawChildOptions = children\n ? Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const option = child as ReactElement<SelectChildProps>;\n const stringValue = String(option.props.value);\n return {\n index,\n label: nodeToLabel(option.props.children),\n originalValue: option.props.value,\n stringValue,\n };\n })\n : undefined;\n const stringValueCounts = new Map<string, number>();\n rawChildOptions?.forEach((option) => {\n stringValueCounts.set(\n option.stringValue,\n (stringValueCounts.get(option.stringValue) ?? 0) + 1,\n );\n });\n const childOptions = rawChildOptions?.map((option) => ({\n ...option,\n value:\n (stringValueCounts.get(option.stringValue) ?? 0) > 1\n ? `${option.stringValue}::${option.index}`\n : option.stringValue,\n }));\n const childValuesByInternalValue = new Map(\n childOptions?.map((option) => [option.value, option.originalValue]),\n );\n const resolveInternalValue = (nextValue: unknown) => {\n if (nextValue == null) return nextValue;\n const matchingOption = childOptions?.find((option) =>\n Object.is(option.originalValue, nextValue),\n );\n return matchingOption?.value ?? String(nextValue);\n };\n const resolveOriginalValue = (nextValue: unknown) => {\n if (nextValue == null) return null;\n return childValuesByInternalValue.has(String(nextValue))\n ? childValuesByInternalValue.get(String(nextValue))\n : nextValue;\n };\n const [uncontrolledOriginalValue, setUncontrolledOriginalValue] = useState(\n defaultValue == null ? null : resolveOriginalValue(resolveInternalValue(defaultValue)),\n );\n const rendersOwnHiddenInput = Boolean(children && name);\n const selectedOriginalValue =\n value === undefined\n ? uncontrolledOriginalValue\n : resolveOriginalValue(resolveInternalValue(value));\n const hiddenValue = selectedOriginalValue == null ? \"\" : String(selectedOriginalValue);\n const mergedComboboxProps = {\n zIndex: overlayZIndexAboveFairmintOverlays,\n ...comboboxProps,\n };\n\n if (!children && !endAdornment) {\n const { comboboxProps: _comboboxProps, onChange: mantineOnChange, ...mantineProps } = props;\n return (\n <MantineSelect\n size=\"md\"\n {...mantineProps}\n comboboxProps={mergedComboboxProps}\n onChange={mantineOnChange as MantineSelectProps[\"onChange\"]}\n ref={ref}\n />\n );\n }\n\n return (\n <>\n <MantineSelect\n size=\"md\"\n classNames={{\n ...classNameMap,\n input: [\"MuiSelect-select\", \"fairmint-select-input\", classNameMap?.input]\n .filter(Boolean)\n .join(\" \"),\n option: [\"fairmint-select-option\", classNameMap?.option].filter(Boolean).join(\" \"),\n }}\n data={children ? childOptions?.map(({ label, value }) => ({ label, value })) : data}\n defaultValue={\n defaultValue == null ? undefined : String(resolveInternalValue(defaultValue))\n }\n hiddenInputProps={rendersOwnHiddenInput ? undefined : hiddenInputProps}\n name={rendersOwnHiddenInput ? undefined : name}\n value={\n value === undefined\n ? undefined\n : value == null\n ? null\n : String(resolveInternalValue(value))\n }\n comboboxProps={mergedComboboxProps}\n rightSection={rightSection || endAdornment}\n styles={styles}\n onChange={(next, option) => {\n if (children) {\n const originalValue = resolveOriginalValue(next);\n if (value === undefined) setUncontrolledOriginalValue(originalValue);\n const event = {\n currentTarget: { name, value: originalValue },\n target: { name, value: originalValue },\n };\n (onChange as LegacySelectChange | undefined)?.(event, option);\n return;\n }\n (onChange as MantineSelectProps[\"onChange\"] | undefined)?.(next, option);\n }}\n {...compatProps}\n ref={ref}\n />\n {rendersOwnHiddenInput ? (\n <input {...hiddenInputProps} name={name} type=\"hidden\" value={hiddenValue} />\n ) : null}\n </>\n );\n },\n);\nSelect.displayName = \"Select\";\n"],"names":["MantineSelect","value"],"mappings":";;;;AA6BA,MAAM,cAAc,CAAC,SAA4B;AAC/C,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAAU,QAAO,OAAO,IAAI;AAC5E,MAAI,MAAM,QAAQ,IAAI,EAAG,QAAO,KAAK,IAAI,WAAW,EAAE,KAAK,EAAE;AAC7D,MAAI,eAAiC,IAAI,UAAU,YAAY,KAAK,MAAM,QAAQ;AAClF,SAAO;AACT;AAEO,MAAM,SAAS;AAAA,EACpB,CAAC,EAAE,UAAU,cAAc,GAAG,MAAA,GAAS,QAAQ;AAC7C,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACD;AACJ,UAAM,eAAe,OAAO,eAAe,aAAa,SAAY;AACpE,UAAM,kBAAkB,WACpB,SAAS,QAAQ,QAAQ,EACtB,OAAO,cAAc,EACrB,IAAI,CAAC,OAAO,UAAU;AACrB,YAAM,SAAS;AACf,YAAM,cAAc,OAAO,OAAO,MAAM,KAAK;AAC7C,aAAO;AAAA,QACL;AAAA,QACA,OAAO,YAAY,OAAO,MAAM,QAAQ;AAAA,QACxC,eAAe,OAAO,MAAM;AAAA,QAC5B;AAAA,MAAA;AAAA,IAEJ,CAAC,IACH;AACJ,UAAM,wCAAwB,IAAA;A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AA,QAAA;AAAA,MAAA;AAAA,MAED,wBACC,oBAAC,SAAA,EAAO,GAAG,kBAAkB,MAAY,MAAK,UAAS,OAAO,YAAA,CAAa,IACzE;AAAA,IAAA,GACN;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;"}
|
|
@@ -16,6 +16,7 @@ const Table = require("../../node_modules/@mantine/core/esm/components/Table/Tab
|
|
|
16
16
|
const Accordion$1 = require("../../node_modules/@mantine/core/esm/components/Accordion/Accordion.cjs");
|
|
17
17
|
const Text = require("../../node_modules/@mantine/core/esm/components/Text/Text.cjs");
|
|
18
18
|
const MultiSelect = require("../../node_modules/@mantine/core/esm/components/MultiSelect/MultiSelect.cjs");
|
|
19
|
+
const zIndex = require("../../theme/zIndex.cjs");
|
|
19
20
|
const Select = require("../../node_modules/@mantine/core/esm/components/Select/Select.cjs");
|
|
20
21
|
const Box = require("../../node_modules/@mantine/core/esm/core/Box/Box.cjs");
|
|
21
22
|
const Title = require("../../node_modules/@mantine/core/esm/components/Title/Title.cjs");
|
|
@@ -1231,6 +1232,7 @@ function Autocomplete(componentProps) {
|
|
|
1231
1232
|
filterOptions,
|
|
1232
1233
|
freeSolo,
|
|
1233
1234
|
fullWidth,
|
|
1235
|
+
comboboxProps,
|
|
1234
1236
|
getOptionLabel,
|
|
1235
1237
|
defaultValue,
|
|
1236
1238
|
inputValue,
|
|
@@ -1363,6 +1365,10 @@ function Autocomplete(componentProps) {
|
|
|
1363
1365
|
const commonSelectProps = {
|
|
1364
1366
|
...autocompleteInputProps,
|
|
1365
1367
|
clearable: !disableClearable,
|
|
1368
|
+
comboboxProps: {
|
|
1369
|
+
zIndex: zIndex.overlayZIndexAboveFairmintOverlays,
|
|
1370
|
+
...comboboxProps
|
|
1371
|
+
},
|
|
1366
1372
|
disabled: disabled ?? autocompleteInputProps.disabled,
|
|
1367
1373
|
label: inputProps.label || label,
|
|
1368
1374
|
nothingFoundMessage: _noOptionsText,
|