@contember/react-select 1.3.0-alpha.14 → 1.3.0-alpha.16
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/development/components/MultiSelect.cjs +23 -3
- package/dist/development/components/MultiSelect.cjs.map +1 -1
- package/dist/development/components/MultiSelect.js +23 -3
- package/dist/development/components/MultiSelect.js.map +1 -1
- package/dist/development/components/Select.cjs +23 -3
- package/dist/development/components/Select.cjs.map +1 -1
- package/dist/development/components/Select.js +23 -3
- package/dist/development/components/Select.js.map +1 -1
- package/dist/development/components/SelectDataView.cjs +6 -2
- package/dist/development/components/SelectDataView.cjs.map +1 -1
- package/dist/development/components/SelectDataView.js +6 -2
- package/dist/development/components/SelectDataView.js.map +1 -1
- package/dist/development/components/SelectEachItem.cjs +6 -2
- package/dist/development/components/SelectEachItem.cjs.map +1 -1
- package/dist/development/components/SelectEachItem.js +6 -2
- package/dist/development/components/SelectEachItem.js.map +1 -1
- package/dist/development/components/SelectItemTrigger.cjs +6 -2
- package/dist/development/components/SelectItemTrigger.cjs.map +1 -1
- package/dist/development/components/SelectItemTrigger.js +6 -2
- package/dist/development/components/SelectItemTrigger.js.map +1 -1
- package/dist/development/components/SelectNewItem.cjs +24 -4
- package/dist/development/components/SelectNewItem.cjs.map +1 -1
- package/dist/development/components/SelectNewItem.js +24 -4
- package/dist/development/components/SelectNewItem.js.map +1 -1
- package/dist/development/components/SelectOption.cjs +11 -3
- package/dist/development/components/SelectOption.cjs.map +1 -1
- package/dist/development/components/SelectOption.js +11 -3
- package/dist/development/components/SelectOption.js.map +1 -1
- package/dist/development/components/SelectPlaceholder.cjs +6 -2
- package/dist/development/components/SelectPlaceholder.cjs.map +1 -1
- package/dist/development/components/SelectPlaceholder.js +6 -2
- package/dist/development/components/SelectPlaceholder.js.map +1 -1
- package/dist/development/components/SortableMultiSelect.cjs +31 -3
- package/dist/development/components/SortableMultiSelect.cjs.map +1 -1
- package/dist/development/components/SortableMultiSelect.js +31 -3
- package/dist/development/components/SortableMultiSelect.js.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { useSelectIsSelected } from "../contexts.js";
|
|
4
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
@@ -7,13 +7,21 @@ import { dataAttribute } from "@contember/utilities";
|
|
|
7
7
|
const SelectOption = forwardRef(({ action, ...props }, ref) => {
|
|
8
8
|
const isSelected = useSelectIsSelected();
|
|
9
9
|
const entity = useEntity();
|
|
10
|
-
return /* @__PURE__ */
|
|
10
|
+
return /* @__PURE__ */ jsxDEV(
|
|
11
11
|
Slot,
|
|
12
12
|
{
|
|
13
13
|
ref,
|
|
14
14
|
"data-selected": dataAttribute(isSelected?.(entity)),
|
|
15
15
|
...props
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
void 0,
|
|
18
|
+
false,
|
|
19
|
+
{
|
|
20
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SelectOption.tsx",
|
|
21
|
+
lineNumber: 16,
|
|
22
|
+
columnNumber: 3
|
|
23
|
+
},
|
|
24
|
+
void 0
|
|
17
25
|
);
|
|
18
26
|
});
|
|
19
27
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOption.js","sources":["../../../src/components/SelectOption.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react'\nimport { useSelectIsSelected } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useEntity } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\n\nexport type SelectOptionProps = {\n\tchildren: ReactNode\n\taction?: 'select' | 'unselect' | 'toggle'\n}\n\nexport const SelectOption = forwardRef<HTMLElement, SelectOptionProps>(({ action, ...props }, ref) => {\n\tconst isSelected = useSelectIsSelected()\n\tconst entity = useEntity()\n\treturn (\n\t\t<Slot\n\t\t\tref={ref}\n\t\t\tdata-selected={dataAttribute(isSelected?.(entity))}\n\t\t\t{...props}\n\t\t/>\n\t)\n})\n"],"names":[],"mappings":";;;;;;AAWa,MAAA,eAAe,WAA2C,CAAC,EAAE,QAAQ,GAAG,SAAS,QAAQ;AACrG,QAAM,aAAa;AACnB,QAAM,SAAS;AAEd,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,iBAAe,cAAc,aAAa,MAAM,CAAC;AAAA,MAChD,GAAG;AAAA,IAAA;AAAA,EAAA;
|
|
1
|
+
{"version":3,"file":"SelectOption.js","sources":["../../../src/components/SelectOption.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react'\nimport { useSelectIsSelected } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useEntity } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\n\nexport type SelectOptionProps = {\n\tchildren: ReactNode\n\taction?: 'select' | 'unselect' | 'toggle'\n}\n\nexport const SelectOption = forwardRef<HTMLElement, SelectOptionProps>(({ action, ...props }, ref) => {\n\tconst isSelected = useSelectIsSelected()\n\tconst entity = useEntity()\n\treturn (\n\t\t<Slot\n\t\t\tref={ref}\n\t\t\tdata-selected={dataAttribute(isSelected?.(entity))}\n\t\t\t{...props}\n\t\t/>\n\t)\n})\n"],"names":["this"],"mappings":";;;;;;AAWa,MAAA,eAAe,WAA2C,CAAC,EAAE,QAAQ,GAAG,SAAS,QAAQ;AACrG,QAAM,aAAa;AACnB,QAAM,SAAS;AAEd,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,iBAAe,cAAc,aAAa,MAAM,CAAC;AAAA,MAChD,GAAG;AAAA,IAAA;AAAA,IAHL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAMF,CAAC;"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
4
|
const contexts = require("../contexts.cjs");
|
|
5
5
|
const SelectPlaceholder = ({ children }) => {
|
|
6
6
|
const hasEntities = contexts.useSelectCurrentEntities().length > 0;
|
|
7
|
-
return hasEntities ? null : /* @__PURE__ */
|
|
7
|
+
return hasEntities ? null : /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
|
|
8
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SelectPlaceholder.tsx",
|
|
9
|
+
lineNumber: 6,
|
|
10
|
+
columnNumber: 30
|
|
11
|
+
}, void 0);
|
|
8
12
|
};
|
|
9
13
|
exports.SelectPlaceholder = SelectPlaceholder;
|
|
10
14
|
//# sourceMappingURL=SelectPlaceholder.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPlaceholder.cjs","sources":["../../../src/components/SelectPlaceholder.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useSelectCurrentEntities } from '../contexts'\n\nexport const SelectPlaceholder = ({ children }: { children: ReactNode }) => {\n\tconst hasEntities = useSelectCurrentEntities().length > 0\n\treturn hasEntities ? null : <>{children}</>\n}\n"],"names":["useSelectCurrentEntities","
|
|
1
|
+
{"version":3,"file":"SelectPlaceholder.cjs","sources":["../../../src/components/SelectPlaceholder.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useSelectCurrentEntities } from '../contexts'\n\nexport const SelectPlaceholder = ({ children }: { children: ReactNode }) => {\n\tconst hasEntities = useSelectCurrentEntities().length > 0\n\treturn hasEntities ? null : <>{children}</>\n}\n"],"names":["useSelectCurrentEntities","jsxDEV","Fragment","this"],"mappings":";;;;AAGO,MAAM,oBAAoB,CAAC,EAAE,eAAwC;AACrE,QAAA,cAAcA,SAAAA,2BAA2B,SAAS;AACjD,SAAA,cAAc,OAAOC,qCAAAC,cAAAA,UAAA,EAAG,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAY,GAAAC,MAAA;AACzC;;"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { useSelectCurrentEntities } from "../contexts.js";
|
|
3
3
|
const SelectPlaceholder = ({ children }) => {
|
|
4
4
|
const hasEntities = useSelectCurrentEntities().length > 0;
|
|
5
|
-
return hasEntities ? null : /* @__PURE__ */
|
|
5
|
+
return hasEntities ? null : /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
6
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SelectPlaceholder.tsx",
|
|
7
|
+
lineNumber: 6,
|
|
8
|
+
columnNumber: 30
|
|
9
|
+
}, void 0);
|
|
6
10
|
};
|
|
7
11
|
export {
|
|
8
12
|
SelectPlaceholder
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPlaceholder.js","sources":["../../../src/components/SelectPlaceholder.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useSelectCurrentEntities } from '../contexts'\n\nexport const SelectPlaceholder = ({ children }: { children: ReactNode }) => {\n\tconst hasEntities = useSelectCurrentEntities().length > 0\n\treturn hasEntities ? null : <>{children}</>\n}\n"],"names":[],"mappings":";;AAGO,MAAM,oBAAoB,CAAC,EAAE,eAAwC;AACrE,QAAA,cAAc,2BAA2B,SAAS;AACjD,SAAA,cAAc,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectPlaceholder.js","sources":["../../../src/components/SelectPlaceholder.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useSelectCurrentEntities } from '../contexts'\n\nexport const SelectPlaceholder = ({ children }: { children: ReactNode }) => {\n\tconst hasEntities = useSelectCurrentEntities().length > 0\n\treturn hasEntities ? null : <>{children}</>\n}\n"],"names":["this"],"mappings":";;AAGO,MAAM,oBAAoB,CAAC,EAAE,eAAwC;AACrE,QAAA,cAAc,2BAA2B,SAAS;AACjD,SAAA,cAAc,OAAO,uBAAA,UAAA,EAAG,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAY,GAAAA,MAAA;AACzC;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const contexts = require("../contexts.cjs");
|
|
6
6
|
const reactBinding = require("@contember/react-binding");
|
|
@@ -28,9 +28,37 @@ const SortableMultiSelect = reactBinding.Component(({ field, children, sortableB
|
|
|
28
28
|
const isSelected = react.useCallback((entity) => {
|
|
29
29
|
return selectedEntities.includes(entity.id);
|
|
30
30
|
}, [selectedEntities]);
|
|
31
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRepeater.Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.SelectCurrentEntitiesContext.Provider, { value: entitiesArr, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.SelectIsSelectedContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.SelectHandleSelectContext.Provider, { value: handler, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.SelectOptionsContext.Provider, { value: options, children }, void 0, false, {
|
|
32
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
33
|
+
lineNumber: 48,
|
|
34
|
+
columnNumber: 7
|
|
35
|
+
}, void 0) }, void 0, false, {
|
|
36
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
37
|
+
lineNumber: 47,
|
|
38
|
+
columnNumber: 6
|
|
39
|
+
}, void 0) }, void 0, false, {
|
|
40
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
41
|
+
lineNumber: 46,
|
|
42
|
+
columnNumber: 5
|
|
43
|
+
}, void 0) }, void 0, false, {
|
|
44
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
45
|
+
lineNumber: 45,
|
|
46
|
+
columnNumber: 4
|
|
47
|
+
}, void 0) }, void 0, false, {
|
|
48
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
49
|
+
lineNumber: 44,
|
|
50
|
+
columnNumber: 3
|
|
51
|
+
}, void 0);
|
|
32
52
|
}, ({ children, field, sortableBy, connectAt }) => {
|
|
33
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRepeater.Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.HasOne, { field: connectAt, children }, void 0, false, {
|
|
54
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
55
|
+
lineNumber: 59,
|
|
56
|
+
columnNumber: 4
|
|
57
|
+
}, void 0) }, void 0, false, {
|
|
58
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
59
|
+
lineNumber: 58,
|
|
60
|
+
columnNumber: 3
|
|
61
|
+
}, void 0);
|
|
34
62
|
});
|
|
35
63
|
exports.SortableMultiSelect = SortableMultiSelect;
|
|
36
64
|
//# sourceMappingURL=SortableMultiSelect.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortableMultiSelect.cjs","sources":["../../../src/components/SortableMultiSelect.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport { Component, EntityAccessor, HasOne, SugaredQualifiedEntityList, SugaredRelativeEntityList, SugaredRelativeSingleEntity, SugaredRelativeSingleField, useEntityList } from '@contember/react-binding'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\nimport { Repeater } from '@contember/react-repeater'\nimport { SelectEvents } from '../types'\n\nexport type SortableMultiSelectProps =\n\t& {\n\t\tchildren: ReactNode\n\t\tfield: SugaredRelativeEntityList['field']\n\t\toptions: SugaredQualifiedEntityList['entities']\n\t\tsortableBy: SugaredRelativeSingleField['field']\n\t\tconnectAt: SugaredRelativeSingleEntity['field']\n\t}\n\t& SelectEvents\n\nexport const SortableMultiSelect = Component(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\tconst list = useEntityList({ field })\n\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\tconst selectedEntities = useMemo(() => Array.from(list).map(it => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\tif (action === 'toggle') {\n\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect' && isSelected) {\n\t\t\tArray.from(list).find(it => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\tonUnselect?.(entity)\n\t\t} else if (action === 'select' && !isSelected) {\n\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\tonSelect?.(entity)\n\t\t\t})\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\treturn selectedEntities.includes(entity.id)\n\t}, [selectedEntities])\n\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t</Repeater>\n\t)\n}, ({ children, field, sortableBy, connectAt }) => {\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<HasOne field={connectAt}>\n\t\t\t\t{children}\n\t\t\t</HasOne>\n\t\t</Repeater>\n\t)\n})\n\n"],"names":["Component","useEntityList","useMemo","useReferentiallyStableCallback","isSelected","useCallback","
|
|
1
|
+
{"version":3,"file":"SortableMultiSelect.cjs","sources":["../../../src/components/SortableMultiSelect.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport { Component, EntityAccessor, HasOne, SugaredQualifiedEntityList, SugaredRelativeEntityList, SugaredRelativeSingleEntity, SugaredRelativeSingleField, useEntityList } from '@contember/react-binding'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\nimport { Repeater } from '@contember/react-repeater'\nimport { SelectEvents } from '../types'\n\nexport type SortableMultiSelectProps =\n\t& {\n\t\tchildren: ReactNode\n\t\tfield: SugaredRelativeEntityList['field']\n\t\toptions: SugaredQualifiedEntityList['entities']\n\t\tsortableBy: SugaredRelativeSingleField['field']\n\t\tconnectAt: SugaredRelativeSingleEntity['field']\n\t}\n\t& SelectEvents\n\nexport const SortableMultiSelect = Component(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\tconst list = useEntityList({ field })\n\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\tconst selectedEntities = useMemo(() => Array.from(list).map(it => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\tif (action === 'toggle') {\n\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect' && isSelected) {\n\t\t\tArray.from(list).find(it => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\tonUnselect?.(entity)\n\t\t} else if (action === 'select' && !isSelected) {\n\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\tonSelect?.(entity)\n\t\t\t})\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\treturn selectedEntities.includes(entity.id)\n\t}, [selectedEntities])\n\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t</Repeater>\n\t)\n}, ({ children, field, sortableBy, connectAt }) => {\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<HasOne field={connectAt}>\n\t\t\t\t{children}\n\t\t\t</HasOne>\n\t\t</Repeater>\n\t)\n})\n\n"],"names":["Component","useEntityList","useMemo","useReferentiallyStableCallback","isSelected","useCallback","jsxDEV","Repeater","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","this","HasOne"],"mappings":";;;;;;;;AAiBa,MAAA,sBAAsBA,aAAU,UAAA,CAAC,EAAE,OAAO,UAAU,YAAY,WAAW,SAAS,UAAU,iBAA2C;AACrJ,QAAM,OAAOC,aAAAA,cAAc,EAAE,MAAO,CAAA;AAC9B,QAAA,cAAcC,cAAQ,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;AAEpD,QAAA,mBAAmBA,cAAQ,MAAM,MAAM,KAAK,IAAI,EAAE,IAAI,CAAM,OAAA,GAAG,UAAU,EAAE,OAAO,WAAW,EAAE,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;AAE3H,QAAM,UAAUC,WAAA,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,UAAMC,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,QAAI,WAAW,UAAU;AACxB,eAASA,cAAa,aAAa;AAAA,IACpC;AACI,QAAA,WAAW,cAAcA,aAAY;AACxC,YAAM,KAAK,IAAI,EAAE,KAAK,CAAA,OAAM,GAAG,UAAU,EAAE,OAAO,UAAW,CAAA,EAAE,OAAO,OAAO,EAAE,GAAG;AAClF,mBAAa,MAAM;AAAA,IACT,WAAA,WAAW,YAAY,CAACA,aAAY;AAC9C,WAAK,gBAAgB,CAAa,cAAA;AACjC,kBAAA,EAAY,qBAAqB,EAAE,OAAO,UAAA,GAAa,MAAM;AAC7D,mBAAW,MAAM;AAAA,MAAA,CACjB;AAAA,IACF;AAAA,EAAA,CACA;AACK,QAAA,aAAaC,kBAAY,CAAC,WAA2B;AACnD,WAAA,iBAAiB,SAAS,OAAO,EAAE;AAAA,EAAA,GACxC,CAAC,gBAAgB,CAAC;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
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { useMemo, useCallback } from "react";
|
|
3
3
|
import { SelectCurrentEntitiesContext, SelectIsSelectedContext, SelectHandleSelectContext, SelectOptionsContext } from "../contexts.js";
|
|
4
4
|
import { Component, useEntityList, HasOne } from "@contember/react-binding";
|
|
@@ -26,9 +26,37 @@ const SortableMultiSelect = Component(({ field, children, sortableBy, connectAt,
|
|
|
26
26
|
const isSelected = useCallback((entity) => {
|
|
27
27
|
return selectedEntities.includes(entity.id);
|
|
28
28
|
}, [selectedEntities]);
|
|
29
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ jsxDEV(Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsxDEV(SelectCurrentEntitiesContext.Provider, { value: entitiesArr, children: /* @__PURE__ */ jsxDEV(SelectIsSelectedContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxDEV(SelectHandleSelectContext.Provider, { value: handler, children: /* @__PURE__ */ jsxDEV(SelectOptionsContext.Provider, { value: options, children }, void 0, false, {
|
|
30
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
31
|
+
lineNumber: 48,
|
|
32
|
+
columnNumber: 7
|
|
33
|
+
}, void 0) }, void 0, false, {
|
|
34
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
35
|
+
lineNumber: 47,
|
|
36
|
+
columnNumber: 6
|
|
37
|
+
}, void 0) }, void 0, false, {
|
|
38
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
39
|
+
lineNumber: 46,
|
|
40
|
+
columnNumber: 5
|
|
41
|
+
}, void 0) }, void 0, false, {
|
|
42
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
43
|
+
lineNumber: 45,
|
|
44
|
+
columnNumber: 4
|
|
45
|
+
}, void 0) }, void 0, false, {
|
|
46
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
47
|
+
lineNumber: 44,
|
|
48
|
+
columnNumber: 3
|
|
49
|
+
}, void 0);
|
|
30
50
|
}, ({ children, field, sortableBy, connectAt }) => {
|
|
31
|
-
return /* @__PURE__ */
|
|
51
|
+
return /* @__PURE__ */ jsxDEV(Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsxDEV(HasOne, { field: connectAt, children }, void 0, false, {
|
|
52
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
53
|
+
lineNumber: 59,
|
|
54
|
+
columnNumber: 4
|
|
55
|
+
}, void 0) }, void 0, false, {
|
|
56
|
+
fileName: "/__w/interface/interface/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
57
|
+
lineNumber: 58,
|
|
58
|
+
columnNumber: 3
|
|
59
|
+
}, void 0);
|
|
32
60
|
});
|
|
33
61
|
export {
|
|
34
62
|
SortableMultiSelect
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortableMultiSelect.js","sources":["../../../src/components/SortableMultiSelect.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport { Component, EntityAccessor, HasOne, SugaredQualifiedEntityList, SugaredRelativeEntityList, SugaredRelativeSingleEntity, SugaredRelativeSingleField, useEntityList } from '@contember/react-binding'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\nimport { Repeater } from '@contember/react-repeater'\nimport { SelectEvents } from '../types'\n\nexport type SortableMultiSelectProps =\n\t& {\n\t\tchildren: ReactNode\n\t\tfield: SugaredRelativeEntityList['field']\n\t\toptions: SugaredQualifiedEntityList['entities']\n\t\tsortableBy: SugaredRelativeSingleField['field']\n\t\tconnectAt: SugaredRelativeSingleEntity['field']\n\t}\n\t& SelectEvents\n\nexport const SortableMultiSelect = Component(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\tconst list = useEntityList({ field })\n\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\tconst selectedEntities = useMemo(() => Array.from(list).map(it => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\tif (action === 'toggle') {\n\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect' && isSelected) {\n\t\t\tArray.from(list).find(it => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\tonUnselect?.(entity)\n\t\t} else if (action === 'select' && !isSelected) {\n\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\tonSelect?.(entity)\n\t\t\t})\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\treturn selectedEntities.includes(entity.id)\n\t}, [selectedEntities])\n\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t</Repeater>\n\t)\n}, ({ children, field, sortableBy, connectAt }) => {\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<HasOne field={connectAt}>\n\t\t\t\t{children}\n\t\t\t</HasOne>\n\t\t</Repeater>\n\t)\n})\n\n"],"names":["isSelected"],"mappings":";;;;;;AAiBa,MAAA,sBAAsB,UAAU,CAAC,EAAE,OAAO,UAAU,YAAY,WAAW,SAAS,UAAU,iBAA2C;AACrJ,QAAM,OAAO,cAAc,EAAE,MAAO,CAAA;AAC9B,QAAA,cAAc,QAAQ,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;AAEpD,QAAA,mBAAmB,QAAQ,MAAM,MAAM,KAAK,IAAI,EAAE,IAAI,CAAM,OAAA,GAAG,UAAU,EAAE,OAAO,WAAW,EAAE,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;AAE3H,QAAM,UAAU,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,UAAMA,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,QAAI,WAAW,UAAU;AACxB,eAASA,cAAa,aAAa;AAAA,IACpC;AACI,QAAA,WAAW,cAAcA,aAAY;AACxC,YAAM,KAAK,IAAI,EAAE,KAAK,CAAA,OAAM,GAAG,UAAU,EAAE,OAAO,UAAW,CAAA,EAAE,OAAO,OAAO,EAAE,GAAG;AAClF,mBAAa,MAAM;AAAA,IACT,WAAA,WAAW,YAAY,CAACA,aAAY;AAC9C,WAAK,gBAAgB,CAAa,cAAA;AACjC,kBAAA,EAAY,qBAAqB,EAAE,OAAO,UAAA,GAAa,MAAM;AAC7D,mBAAW,MAAM;AAAA,MAAA,CACjB;AAAA,IACF;AAAA,EAAA,CACA;AACK,QAAA,aAAa,YAAY,CAAC,WAA2B;AACnD,WAAA,iBAAiB,SAAS,OAAO,EAAE;AAAA,EAAA,GACxC,CAAC,gBAAgB,CAAC;AAErB,SACE,
|
|
1
|
+
{"version":3,"file":"SortableMultiSelect.js","sources":["../../../src/components/SortableMultiSelect.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport { Component, EntityAccessor, HasOne, SugaredQualifiedEntityList, SugaredRelativeEntityList, SugaredRelativeSingleEntity, SugaredRelativeSingleField, useEntityList } from '@contember/react-binding'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\nimport { Repeater } from '@contember/react-repeater'\nimport { SelectEvents } from '../types'\n\nexport type SortableMultiSelectProps =\n\t& {\n\t\tchildren: ReactNode\n\t\tfield: SugaredRelativeEntityList['field']\n\t\toptions: SugaredQualifiedEntityList['entities']\n\t\tsortableBy: SugaredRelativeSingleField['field']\n\t\tconnectAt: SugaredRelativeSingleEntity['field']\n\t}\n\t& SelectEvents\n\nexport const SortableMultiSelect = Component(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\tconst list = useEntityList({ field })\n\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\tconst selectedEntities = useMemo(() => Array.from(list).map(it => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\tif (action === 'toggle') {\n\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect' && isSelected) {\n\t\t\tArray.from(list).find(it => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\tonUnselect?.(entity)\n\t\t} else if (action === 'select' && !isSelected) {\n\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\tonSelect?.(entity)\n\t\t\t})\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\treturn selectedEntities.includes(entity.id)\n\t}, [selectedEntities])\n\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t</Repeater>\n\t)\n}, ({ children, field, sortableBy, connectAt }) => {\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t<HasOne field={connectAt}>\n\t\t\t\t{children}\n\t\t\t</HasOne>\n\t\t</Repeater>\n\t)\n})\n\n"],"names":["isSelected","this"],"mappings":";;;;;;AAiBa,MAAA,sBAAsB,UAAU,CAAC,EAAE,OAAO,UAAU,YAAY,WAAW,SAAS,UAAU,iBAA2C;AACrJ,QAAM,OAAO,cAAc,EAAE,MAAO,CAAA;AAC9B,QAAA,cAAc,QAAQ,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;AAEpD,QAAA,mBAAmB,QAAQ,MAAM,MAAM,KAAK,IAAI,EAAE,IAAI,CAAM,OAAA,GAAG,UAAU,EAAE,OAAO,WAAW,EAAE,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;AAE3H,QAAM,UAAU,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,UAAMA,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,QAAI,WAAW,UAAU;AACxB,eAASA,cAAa,aAAa;AAAA,IACpC;AACI,QAAA,WAAW,cAAcA,aAAY;AACxC,YAAM,KAAK,IAAI,EAAE,KAAK,CAAA,OAAM,GAAG,UAAU,EAAE,OAAO,UAAW,CAAA,EAAE,OAAO,OAAO,EAAE,GAAG;AAClF,mBAAa,MAAM;AAAA,IACT,WAAA,WAAW,YAAY,CAACA,aAAY;AAC9C,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