@contember/react-select 2.1.0-alpha.36 → 2.1.0-alpha.39
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/index.cjs +30 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +30 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/components/MultiSelect.cjs +54 -0
- package/dist/development/src/components/MultiSelect.cjs.map +1 -0
- package/dist/development/src/components/MultiSelect.js +54 -0
- package/dist/development/src/components/MultiSelect.js.map +1 -0
- package/dist/development/src/components/Select.cjs +52 -0
- package/dist/development/src/components/Select.cjs.map +1 -0
- package/dist/development/src/components/Select.js +52 -0
- package/dist/development/src/components/Select.js.map +1 -0
- package/dist/development/src/components/SelectDataView.cjs +30 -0
- package/dist/development/src/components/SelectDataView.cjs.map +1 -0
- package/dist/development/src/components/SelectDataView.js +30 -0
- package/dist/development/src/components/SelectDataView.js.map +1 -0
- package/dist/development/src/components/SelectEachItem.cjs +15 -0
- package/dist/development/src/components/SelectEachItem.cjs.map +1 -0
- package/dist/development/src/components/SelectEachItem.js +15 -0
- package/dist/development/src/components/SelectEachItem.js.map +1 -0
- package/dist/development/src/components/SelectItemTrigger.cjs +23 -0
- package/dist/development/src/components/SelectItemTrigger.cjs.map +1 -0
- package/dist/development/src/components/SelectItemTrigger.js +23 -0
- package/dist/development/src/components/SelectItemTrigger.js.map +1 -0
- package/dist/development/src/components/SelectNewItem.cjs +75 -0
- package/dist/development/src/components/SelectNewItem.cjs.map +1 -0
- package/dist/development/src/components/SelectNewItem.js +75 -0
- package/dist/development/src/components/SelectNewItem.js.map +1 -0
- package/dist/development/src/components/SelectOption.cjs +30 -0
- package/dist/development/src/components/SelectOption.cjs.map +1 -0
- package/dist/development/src/components/SelectOption.js +30 -0
- package/dist/development/src/components/SelectOption.js.map +1 -0
- package/dist/development/src/components/SelectPlaceholder.cjs +14 -0
- package/dist/development/src/components/SelectPlaceholder.cjs.map +1 -0
- package/dist/development/src/components/SelectPlaceholder.js +14 -0
- package/dist/development/src/components/SelectPlaceholder.js.map +1 -0
- package/dist/development/src/components/SortableMultiSelect.cjs +81 -0
- package/dist/development/src/components/SortableMultiSelect.cjs.map +1 -0
- package/dist/development/src/components/SortableMultiSelect.js +81 -0
- package/dist/development/src/components/SortableMultiSelect.js.map +1 -0
- package/dist/development/src/contexts.cjs +24 -0
- package/dist/development/src/contexts.cjs.map +1 -0
- package/dist/development/src/contexts.js +24 -0
- package/dist/development/src/contexts.js.map +1 -0
- package/dist/production/index.cjs +30 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +30 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/components/MultiSelect.cjs +34 -0
- package/dist/production/src/components/MultiSelect.cjs.map +1 -0
- package/dist/production/src/components/MultiSelect.js +34 -0
- package/dist/production/src/components/MultiSelect.js.map +1 -0
- package/dist/production/src/components/Select.cjs +32 -0
- package/dist/production/src/components/Select.cjs.map +1 -0
- package/dist/production/src/components/Select.js +32 -0
- package/dist/production/src/components/Select.js.map +1 -0
- package/dist/production/src/components/SelectDataView.cjs +22 -0
- package/dist/production/src/components/SelectDataView.cjs.map +1 -0
- package/dist/production/src/components/SelectDataView.js +22 -0
- package/dist/production/src/components/SelectDataView.js.map +1 -0
- package/dist/production/src/components/SelectEachItem.cjs +11 -0
- package/dist/production/src/components/SelectEachItem.cjs.map +1 -0
- package/dist/production/src/components/SelectEachItem.js +11 -0
- package/dist/production/src/components/SelectEachItem.js.map +1 -0
- package/dist/production/src/components/SelectItemTrigger.cjs +19 -0
- package/dist/production/src/components/SelectItemTrigger.cjs.map +1 -0
- package/dist/production/src/components/SelectItemTrigger.js +19 -0
- package/dist/production/src/components/SelectItemTrigger.js.map +1 -0
- package/dist/production/src/components/SelectNewItem.cjs +51 -0
- package/dist/production/src/components/SelectNewItem.cjs.map +1 -0
- package/dist/production/src/components/SelectNewItem.js +51 -0
- package/dist/production/src/components/SelectNewItem.js.map +1 -0
- package/dist/production/src/components/SelectOption.cjs +22 -0
- package/dist/production/src/components/SelectOption.cjs.map +1 -0
- package/dist/production/src/components/SelectOption.js +22 -0
- package/dist/production/src/components/SelectOption.js.map +1 -0
- package/dist/production/src/components/SelectPlaceholder.cjs +10 -0
- package/dist/production/src/components/SelectPlaceholder.cjs.map +1 -0
- package/dist/production/src/components/SelectPlaceholder.js +10 -0
- package/dist/production/src/components/SelectPlaceholder.js.map +1 -0
- package/dist/production/src/components/SortableMultiSelect.cjs +53 -0
- package/dist/production/src/components/SortableMultiSelect.cjs.map +1 -0
- package/dist/production/src/components/SortableMultiSelect.js +53 -0
- package/dist/production/src/components/SortableMultiSelect.js.map +1 -0
- package/dist/production/src/contexts.cjs +24 -0
- package/dist/production/src/contexts.cjs.map +1 -0
- package/dist/production/src/contexts.js +24 -0
- package/dist/production/src/contexts.js.map +1 -0
- package/dist/types/components/MultiSelect.d.ts +14 -0
- package/dist/types/components/MultiSelect.d.ts.map +1 -0
- package/dist/types/components/Select.d.ts +16 -0
- package/dist/types/components/Select.d.ts.map +1 -0
- package/dist/types/components/SelectDataView.d.ts +7 -0
- package/dist/types/components/SelectDataView.d.ts.map +1 -0
- package/dist/types/components/SelectEachItem.d.ts +5 -0
- package/dist/types/components/SelectEachItem.d.ts.map +1 -0
- package/dist/types/components/SelectItemTrigger.d.ts +8 -0
- package/dist/types/components/SelectItemTrigger.d.ts.map +1 -0
- package/dist/types/components/SelectNewItem.d.ts +5 -0
- package/dist/types/components/SelectNewItem.d.ts.map +1 -0
- package/dist/types/components/SelectOption.d.ts +7 -0
- package/dist/types/components/SelectOption.d.ts.map +1 -0
- package/dist/types/components/SelectPlaceholder.d.ts +5 -0
- package/dist/types/components/SelectPlaceholder.d.ts.map +1 -0
- package/dist/types/components/SortableMultiSelect.d.ts +18 -0
- package/dist/types/components/SortableMultiSelect.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +10 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/contexts.d.ts +23 -0
- package/dist/types/contexts.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types/events.d.ts +6 -0
- package/dist/types/types/events.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useEnvironment, QueryLanguage, useExtendTree, useGetEntitySubTree, EntitySubTree, TreeRootIdProvider, Entity } from "@contember/react-binding";
|
|
3
|
+
import { useMemo, useState, useEffect } from "react";
|
|
4
|
+
import { useSelectOptions } from "../contexts.js";
|
|
5
|
+
const SelectNewItem = ({ children }) => {
|
|
6
|
+
const options = useSelectOptions();
|
|
7
|
+
const env = useEnvironment();
|
|
8
|
+
const { entityName } = useMemo(() => QueryLanguage.desugarQualifiedEntityList({ entities: options }, env), [env, options]);
|
|
9
|
+
const [state, setState] = useState(null);
|
|
10
|
+
const extendTree = useExtendTree();
|
|
11
|
+
const getSubTree = useGetEntitySubTree();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
(async () => {
|
|
14
|
+
const treeRootId = await extendTree(
|
|
15
|
+
/* @__PURE__ */ jsxDEV(Fragment, { children: /* @__PURE__ */ jsxDEV(
|
|
16
|
+
EntitySubTree,
|
|
17
|
+
{
|
|
18
|
+
entity: {
|
|
19
|
+
entityName
|
|
20
|
+
},
|
|
21
|
+
expectedMutation: "none",
|
|
22
|
+
isUnpersisted: true,
|
|
23
|
+
isCreating: true,
|
|
24
|
+
children
|
|
25
|
+
},
|
|
26
|
+
void 0,
|
|
27
|
+
false,
|
|
28
|
+
{
|
|
29
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
30
|
+
lineNumber: 29,
|
|
31
|
+
columnNumber: 6
|
|
32
|
+
},
|
|
33
|
+
void 0
|
|
34
|
+
) }, void 0, false, {
|
|
35
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
36
|
+
lineNumber: 28,
|
|
37
|
+
columnNumber: 5
|
|
38
|
+
}, void 0)
|
|
39
|
+
);
|
|
40
|
+
if (!treeRootId) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const entity = getSubTree({
|
|
44
|
+
entity: {
|
|
45
|
+
entityName
|
|
46
|
+
},
|
|
47
|
+
isCreating: true
|
|
48
|
+
}, treeRootId);
|
|
49
|
+
setState({
|
|
50
|
+
entity,
|
|
51
|
+
treeRootId
|
|
52
|
+
});
|
|
53
|
+
})();
|
|
54
|
+
}, [children, entityName, extendTree, getSubTree]);
|
|
55
|
+
if (!state) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: /* @__PURE__ */ jsxDEV(TreeRootIdProvider, { treeRootId: state.treeRootId, children: /* @__PURE__ */ jsxDEV(Entity, { accessor: state.entity, children }, void 0, false, {
|
|
59
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
60
|
+
lineNumber: 65,
|
|
61
|
+
columnNumber: 5
|
|
62
|
+
}, void 0) }, void 0, false, {
|
|
63
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
64
|
+
lineNumber: 64,
|
|
65
|
+
columnNumber: 4
|
|
66
|
+
}, void 0) }, void 0, false, {
|
|
67
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
68
|
+
lineNumber: 63,
|
|
69
|
+
columnNumber: 3
|
|
70
|
+
}, void 0);
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
SelectNewItem
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=SelectNewItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectNewItem.js","sources":["../../../../../packages/react-select/src/components/SelectNewItem.tsx"],"sourcesContent":["import {\n\tEntity,\n\tEntityAccessor,\n\tEntitySubTree,\n\tQueryLanguage,\n\tTreeRootId,\n\tTreeRootIdProvider,\n\tuseEnvironment,\n\tuseExtendTree,\n\tuseGetEntitySubTree,\n} from '@contember/react-binding'\nimport * as React from 'react'\nimport { ReactNode, useEffect, useMemo, useState } from 'react'\nimport { useSelectOptions } from '../contexts'\n\nexport const SelectNewItem = ({ children }: { children: ReactNode }) => {\n\tconst options = useSelectOptions()\n\tconst env = useEnvironment()\n\tconst { entityName } = useMemo(() => QueryLanguage.desugarQualifiedEntityList({ entities: options }, env), [env, options])\n\n\tconst [state, setState] = useState<{ entity: EntityAccessor; treeRootId: TreeRootId } | null>(null)\n\tconst extendTree = useExtendTree()\n\tconst getSubTree = useGetEntitySubTree()\n\n\tuseEffect(() => {\n\t\t;(async () => {\n\t\t\tconst treeRootId = await extendTree(\n\t\t\t\t<>\n\t\t\t\t\t<EntitySubTree\n\t\t\t\t\t\tentity={{\n\t\t\t\t\t\t\tentityName,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\texpectedMutation={'none'}\n\t\t\t\t\t\tisUnpersisted\n\t\t\t\t\t\tisCreating\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</EntitySubTree>\n\t\t\t\t</>,\n\t\t\t)\n\t\t\tif (!treeRootId) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst entity = getSubTree({\n\t\t\t\tentity: {\n\t\t\t\t\tentityName: entityName,\n\t\t\t\t},\n\t\t\t\tisCreating: true,\n\t\t\t}, treeRootId)\n\t\t\tsetState({\n\t\t\t\tentity,\n\t\t\t\ttreeRootId,\n\t\t\t})\n\t\t})()\n\t}, [children, entityName, extendTree, getSubTree])\n\n\tif (!state) {\n\t\treturn null\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<TreeRootIdProvider treeRootId={state.treeRootId}>\n\t\t\t\t<Entity accessor={state.entity}>\n\t\t\t\t\t{children}\n\t\t\t\t</Entity>\n\t\t\t</TreeRootIdProvider>\n\t\t</>\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAeO,MAAM,gBAAgB,CAAC,EAAE,eAAwC;AACvE,QAAM,UAAU,iBAAA;AAChB,QAAM,MAAM,eAAA;AACZ,QAAM,EAAE,WAAA,IAAe,QAAQ,MAAM,cAAc,2BAA2B,EAAE,UAAU,QAAA,GAAW,GAAG,GAAG,CAAC,KAAK,OAAO,CAAC;AAEzH,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoE,IAAI;AAClG,QAAM,aAAa,cAAA;AACnB,QAAM,aAAa,oBAAA;AAEnB,YAAU,MAAM;AACd,KAAC,YAAY;AACb,YAAM,aAAa,MAAM;AAAA,QACxB,uBAAA,UAAA,EACC,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACA,QAAQ;AAAA,cACP;AAAA,YAAA;AAAA,YAED,kBAAkB;AAAA,YAClB,eAAa;AAAA,YACb,YAAU;AAAA,YAET;AAAA,UAAA;AAAA,UARF;AAAA,UAAA;AAAA,UAAA;AAAA,YAAA,UAAA;AAAA,YAAA,YAAA;AAAA,YAAA,cAAA;AAAA,UAAA;AAAA,UAAAA;AAAAA,QAAA,EASA,GAVD,QAAA,OAAA;AAAA,UAAA,UAAA;AAAA,UAAA,YAAA;AAAA,UAAA,cAAA;AAAA,QAAA,GAAAA,MAWA;AAAA,MAAA;AAED,UAAI,CAAC,YAAY;AAChB;AAAA,MACD;AAEA,YAAM,SAAS,WAAW;AAAA,QACzB,QAAQ;AAAA,UACP;AAAA,QAAA;AAAA,QAED,YAAY;AAAA,MAAA,GACV,UAAU;AACb,eAAS;AAAA,QACR;AAAA,QACA;AAAA,MAAA,CACA;AAAA,IACF,GAAA;AAAA,EACD,GAAG,CAAC,UAAU,YAAY,YAAY,UAAU,CAAC;AAEjD,MAAI,CAAC,OAAO;AACX,WAAO;AAAA,EACR;AAEA,SACC,uBAAA,UAAA,EACC,UAAA,uBAAC,oBAAA,EAAmB,YAAY,MAAM,YACrC,UAAA,uBAAC,QAAA,EAAO,UAAU,MAAM,QACtB,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EAAA,GALD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA;AAEF;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const contexts = require("../contexts.cjs");
|
|
6
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
7
|
+
const reactBinding = require("@contember/react-binding");
|
|
8
|
+
const utilities = require("@contember/utilities");
|
|
9
|
+
const SelectOption = React.forwardRef(({ action, ...props }, ref) => {
|
|
10
|
+
const isSelected = contexts.useSelectIsSelected();
|
|
11
|
+
const entity = reactBinding.useEntity();
|
|
12
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
13
|
+
reactSlot.Slot,
|
|
14
|
+
{
|
|
15
|
+
ref,
|
|
16
|
+
"data-selected": utilities.dataAttribute(isSelected?.(entity)),
|
|
17
|
+
...props
|
|
18
|
+
},
|
|
19
|
+
void 0,
|
|
20
|
+
false,
|
|
21
|
+
{
|
|
22
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectOption.tsx",
|
|
23
|
+
lineNumber: 16,
|
|
24
|
+
columnNumber: 3
|
|
25
|
+
},
|
|
26
|
+
void 0
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
exports.SelectOption = SelectOption;
|
|
30
|
+
//# sourceMappingURL=SelectOption.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectOption.cjs","sources":["../../../../../packages/react-select/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":["forwardRef","useSelectIsSelected","useEntity","jsxDEV","Slot","dataAttribute","this"],"mappings":";;;;;;;;AAWO,MAAM,eAAeA,MAAAA,WAA2C,CAAC,EAAE,QAAQ,GAAG,MAAA,GAAS,QAAQ;AACrG,QAAM,aAAaC,SAAAA,oBAAA;AACnB,QAAM,SAASC,aAAAA,UAAA;AACf,SACCC,8BAAAA;AAAAA,IAACC,UAAAA;AAAAA,IAAA;AAAA,MACA;AAAA,MACA,iBAAeC,UAAAA,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,IAAAC;AAAAA,EAAA;AAMF,CAAC;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useSelectIsSelected } from "../contexts.js";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { useEntity } from "@contember/react-binding";
|
|
6
|
+
import { dataAttribute } from "@contember/utilities";
|
|
7
|
+
const SelectOption = forwardRef(({ action, ...props }, ref) => {
|
|
8
|
+
const isSelected = useSelectIsSelected();
|
|
9
|
+
const entity = useEntity();
|
|
10
|
+
return /* @__PURE__ */ jsxDEV(
|
|
11
|
+
Slot,
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
"data-selected": dataAttribute(isSelected?.(entity)),
|
|
15
|
+
...props
|
|
16
|
+
},
|
|
17
|
+
void 0,
|
|
18
|
+
false,
|
|
19
|
+
{
|
|
20
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectOption.tsx",
|
|
21
|
+
lineNumber: 16,
|
|
22
|
+
columnNumber: 3
|
|
23
|
+
},
|
|
24
|
+
void 0
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
SelectOption
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=SelectOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectOption.js","sources":["../../../../../packages/react-select/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":";;;;;;AAWO,MAAM,eAAe,WAA2C,CAAC,EAAE,QAAQ,GAAG,MAAA,GAAS,QAAQ;AACrG,QAAM,aAAa,oBAAA;AACnB,QAAM,SAAS,UAAA;AACf,SACC;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;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const contexts = require("../contexts.cjs");
|
|
5
|
+
const SelectPlaceholder = ({ children }) => {
|
|
6
|
+
const hasEntities = contexts.useSelectCurrentEntities().length > 0;
|
|
7
|
+
return hasEntities ? null : /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
|
|
8
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectPlaceholder.tsx",
|
|
9
|
+
lineNumber: 6,
|
|
10
|
+
columnNumber: 30
|
|
11
|
+
}, void 0);
|
|
12
|
+
};
|
|
13
|
+
exports.SelectPlaceholder = SelectPlaceholder;
|
|
14
|
+
//# sourceMappingURL=SelectPlaceholder.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectPlaceholder.cjs","sources":["../../../../../packages/react-select/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;AAC3E,QAAM,cAAcA,SAAAA,2BAA2B,SAAS;AACxD,SAAO,cAAc,OAAOC,qCAAAC,cAAAA,UAAA,EAAG,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAAY;AACzC;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useSelectCurrentEntities } from "../contexts.js";
|
|
3
|
+
const SelectPlaceholder = ({ children }) => {
|
|
4
|
+
const hasEntities = useSelectCurrentEntities().length > 0;
|
|
5
|
+
return hasEntities ? null : /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
6
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectPlaceholder.tsx",
|
|
7
|
+
lineNumber: 6,
|
|
8
|
+
columnNumber: 30
|
|
9
|
+
}, void 0);
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
SelectPlaceholder
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=SelectPlaceholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectPlaceholder.js","sources":["../../../../../packages/react-select/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;AAC3E,QAAM,cAAc,2BAA2B,SAAS;AACxD,SAAO,cAAc,OAAO,uBAAA,UAAA,EAAG,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAY;AACzC;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const contexts = require("../contexts.cjs");
|
|
6
|
+
const reactBinding = require("@contember/react-binding");
|
|
7
|
+
const reactUtils = require("@contember/react-utils");
|
|
8
|
+
const reactRepeater = require("@contember/react-repeater");
|
|
9
|
+
const SortableMultiSelect = reactBinding.Component(
|
|
10
|
+
({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }) => {
|
|
11
|
+
const list = reactBinding.useEntityList({ field });
|
|
12
|
+
const entitiesArr = React.useMemo(() => Array.from(list), [list]);
|
|
13
|
+
const optionsMarker = React.useMemo(() => {
|
|
14
|
+
const desugared = reactBinding.QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment);
|
|
15
|
+
let marker = list.getMarker();
|
|
16
|
+
for (let relation of desugared.hasOneRelationPath) {
|
|
17
|
+
const placeholder = reactBinding.PlaceholderGenerator.getHasOneRelationPlaceholder(relation);
|
|
18
|
+
const relationMarker = marker.fields.markers.get(placeholder);
|
|
19
|
+
if (!relationMarker || relationMarker instanceof reactBinding.FieldMarker) {
|
|
20
|
+
throw new Error("Invalid marker");
|
|
21
|
+
}
|
|
22
|
+
marker = relationMarker;
|
|
23
|
+
}
|
|
24
|
+
return marker;
|
|
25
|
+
}, [connectAt, list]);
|
|
26
|
+
options ?? (options = optionsMarker.environment.getSubTreeNode().entity.name);
|
|
27
|
+
const selectedEntities = React.useMemo(() => Array.from(list).map((it) => it.getEntity({ field: connectAt }).id), [connectAt, list]);
|
|
28
|
+
const handler = reactUtils.useReferentiallyStableCallback((entity, action = "toggle") => {
|
|
29
|
+
const isSelected2 = selectedEntities.includes(entity.id);
|
|
30
|
+
if (action === "toggle") {
|
|
31
|
+
action = isSelected2 ? "unselect" : "select";
|
|
32
|
+
}
|
|
33
|
+
if (action === "unselect" && isSelected2) {
|
|
34
|
+
Array.from(list).find((it) => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity();
|
|
35
|
+
onUnselect?.(entity);
|
|
36
|
+
} else if (action === "select" && !isSelected2) {
|
|
37
|
+
list.createNewEntity((getEntity) => {
|
|
38
|
+
getEntity().connectEntityAtField({ field: connectAt }, entity);
|
|
39
|
+
onSelect?.(entity);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const isSelected = React.useCallback((entity) => {
|
|
44
|
+
return selectedEntities.includes(entity.id);
|
|
45
|
+
}, [selectedEntities]);
|
|
46
|
+
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, {
|
|
47
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
48
|
+
lineNumber: 81,
|
|
49
|
+
columnNumber: 8
|
|
50
|
+
}, void 0) }, void 0, false, {
|
|
51
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
52
|
+
lineNumber: 80,
|
|
53
|
+
columnNumber: 7
|
|
54
|
+
}, void 0) }, void 0, false, {
|
|
55
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
56
|
+
lineNumber: 79,
|
|
57
|
+
columnNumber: 6
|
|
58
|
+
}, void 0) }, void 0, false, {
|
|
59
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
60
|
+
lineNumber: 78,
|
|
61
|
+
columnNumber: 5
|
|
62
|
+
}, void 0) }, void 0, false, {
|
|
63
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
64
|
+
lineNumber: 77,
|
|
65
|
+
columnNumber: 4
|
|
66
|
+
}, void 0);
|
|
67
|
+
},
|
|
68
|
+
({ children, field, sortableBy, connectAt }) => {
|
|
69
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRepeater.Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.HasOne, { field: connectAt, expectedMutation: "connectOrDisconnect", children }, void 0, false, {
|
|
70
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
71
|
+
lineNumber: 93,
|
|
72
|
+
columnNumber: 5
|
|
73
|
+
}, void 0) }, void 0, false, {
|
|
74
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
75
|
+
lineNumber: 92,
|
|
76
|
+
columnNumber: 4
|
|
77
|
+
}, void 0);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
exports.SortableMultiSelect = SortableMultiSelect;
|
|
81
|
+
//# sourceMappingURL=SortableMultiSelect.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableMultiSelect.cjs","sources":["../../../../../packages/react-select/src/components/SortableMultiSelect.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport {\n\tComponent,\n\tEntityAccessor,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOne,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tQueryLanguage,\n\tSugaredQualifiedEntityList,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tuseEntityList,\n} 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(\n\t({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\t\tconst list = useEntityList({ field })\n\t\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\t\tconst optionsMarker = useMemo(() => {\n\t\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment)\n\t\t\tlet marker: HasOneRelationMarker | HasManyRelationMarker | EntitySubTreeMarker | EntityListSubTreeMarker = list.getMarker()\n\t\t\tfor (let relation of desugared.hasOneRelationPath) {\n\t\t\t\tconst placeholder = PlaceholderGenerator.getHasOneRelationPlaceholder(relation)\n\t\t\t\tconst relationMarker = marker.fields.markers.get(placeholder)\n\t\t\t\tif (!relationMarker || relationMarker instanceof FieldMarker) {\n\t\t\t\t\tthrow new Error('Invalid marker')\n\t\t\t\t}\n\t\t\t\tmarker = relationMarker\n\t\t\t}\n\t\t\treturn marker\n\t\t}, [connectAt, list])\n\n\t\toptions ??= optionsMarker.environment.getSubTreeNode().entity.name\n\n\t\tconst selectedEntities = useMemo(() => Array.from(list).map((it: EntityAccessor) => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\t\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\t\tif (action === 'toggle') {\n\t\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t\t}\n\t\t\tif (action === 'unselect' && isSelected) {\n\t\t\t\tArray.from(list).find((it: EntityAccessor) => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\t\tonUnselect?.(entity)\n\t\t\t} else if (action === 'select' && !isSelected) {\n\t\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\t\tonSelect?.(entity)\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\t\treturn selectedEntities.includes(entity.id)\n\t\t}, [selectedEntities])\n\n\t\treturn (\n\t\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t\t</Repeater>\n\t\t)\n\t},\n\t({ children, field, sortableBy, connectAt }) => {\n\t\treturn (\n\t\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t\t<HasOne field={connectAt} expectedMutation=\"connectOrDisconnect\">\n\t\t\t\t\t{children}\n\t\t\t\t</HasOne>\n\t\t\t</Repeater>\n\t\t)\n\t},\n)\n"],"names":["Component","useEntityList","useMemo","QueryLanguage","PlaceholderGenerator","FieldMarker","useReferentiallyStableCallback","isSelected","useCallback","jsxDEV","Repeater","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","this","HasOne"],"mappings":"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"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useMemo, useCallback } from "react";
|
|
3
|
+
import { SelectCurrentEntitiesContext, SelectIsSelectedContext, SelectHandleSelectContext, SelectOptionsContext } from "../contexts.js";
|
|
4
|
+
import { Component, useEntityList, QueryLanguage, PlaceholderGenerator, FieldMarker, HasOne } from "@contember/react-binding";
|
|
5
|
+
import { useReferentiallyStableCallback } from "@contember/react-utils";
|
|
6
|
+
import { Repeater } from "@contember/react-repeater";
|
|
7
|
+
const SortableMultiSelect = Component(
|
|
8
|
+
({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }) => {
|
|
9
|
+
const list = useEntityList({ field });
|
|
10
|
+
const entitiesArr = useMemo(() => Array.from(list), [list]);
|
|
11
|
+
const optionsMarker = useMemo(() => {
|
|
12
|
+
const desugared = QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment);
|
|
13
|
+
let marker = list.getMarker();
|
|
14
|
+
for (let relation of desugared.hasOneRelationPath) {
|
|
15
|
+
const placeholder = PlaceholderGenerator.getHasOneRelationPlaceholder(relation);
|
|
16
|
+
const relationMarker = marker.fields.markers.get(placeholder);
|
|
17
|
+
if (!relationMarker || relationMarker instanceof FieldMarker) {
|
|
18
|
+
throw new Error("Invalid marker");
|
|
19
|
+
}
|
|
20
|
+
marker = relationMarker;
|
|
21
|
+
}
|
|
22
|
+
return marker;
|
|
23
|
+
}, [connectAt, list]);
|
|
24
|
+
options ?? (options = optionsMarker.environment.getSubTreeNode().entity.name);
|
|
25
|
+
const selectedEntities = useMemo(() => Array.from(list).map((it) => it.getEntity({ field: connectAt }).id), [connectAt, list]);
|
|
26
|
+
const handler = useReferentiallyStableCallback((entity, action = "toggle") => {
|
|
27
|
+
const isSelected2 = selectedEntities.includes(entity.id);
|
|
28
|
+
if (action === "toggle") {
|
|
29
|
+
action = isSelected2 ? "unselect" : "select";
|
|
30
|
+
}
|
|
31
|
+
if (action === "unselect" && isSelected2) {
|
|
32
|
+
Array.from(list).find((it) => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity();
|
|
33
|
+
onUnselect?.(entity);
|
|
34
|
+
} else if (action === "select" && !isSelected2) {
|
|
35
|
+
list.createNewEntity((getEntity) => {
|
|
36
|
+
getEntity().connectEntityAtField({ field: connectAt }, entity);
|
|
37
|
+
onSelect?.(entity);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const isSelected = useCallback((entity) => {
|
|
42
|
+
return selectedEntities.includes(entity.id);
|
|
43
|
+
}, [selectedEntities]);
|
|
44
|
+
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, {
|
|
45
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
46
|
+
lineNumber: 81,
|
|
47
|
+
columnNumber: 8
|
|
48
|
+
}, void 0) }, void 0, false, {
|
|
49
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
50
|
+
lineNumber: 80,
|
|
51
|
+
columnNumber: 7
|
|
52
|
+
}, void 0) }, void 0, false, {
|
|
53
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
54
|
+
lineNumber: 79,
|
|
55
|
+
columnNumber: 6
|
|
56
|
+
}, void 0) }, void 0, false, {
|
|
57
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
58
|
+
lineNumber: 78,
|
|
59
|
+
columnNumber: 5
|
|
60
|
+
}, void 0) }, void 0, false, {
|
|
61
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
62
|
+
lineNumber: 77,
|
|
63
|
+
columnNumber: 4
|
|
64
|
+
}, void 0);
|
|
65
|
+
},
|
|
66
|
+
({ children, field, sortableBy, connectAt }) => {
|
|
67
|
+
return /* @__PURE__ */ jsxDEV(Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsxDEV(HasOne, { field: connectAt, expectedMutation: "connectOrDisconnect", children }, void 0, false, {
|
|
68
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
69
|
+
lineNumber: 93,
|
|
70
|
+
columnNumber: 5
|
|
71
|
+
}, void 0) }, void 0, false, {
|
|
72
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SortableMultiSelect.tsx",
|
|
73
|
+
lineNumber: 92,
|
|
74
|
+
columnNumber: 4
|
|
75
|
+
}, void 0);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
export {
|
|
79
|
+
SortableMultiSelect
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=SortableMultiSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableMultiSelect.js","sources":["../../../../../packages/react-select/src/components/SortableMultiSelect.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport {\n\tComponent,\n\tEntityAccessor,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOne,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tQueryLanguage,\n\tSugaredQualifiedEntityList,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tuseEntityList,\n} 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(\n\t({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\t\tconst list = useEntityList({ field })\n\t\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\t\tconst optionsMarker = useMemo(() => {\n\t\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment)\n\t\t\tlet marker: HasOneRelationMarker | HasManyRelationMarker | EntitySubTreeMarker | EntityListSubTreeMarker = list.getMarker()\n\t\t\tfor (let relation of desugared.hasOneRelationPath) {\n\t\t\t\tconst placeholder = PlaceholderGenerator.getHasOneRelationPlaceholder(relation)\n\t\t\t\tconst relationMarker = marker.fields.markers.get(placeholder)\n\t\t\t\tif (!relationMarker || relationMarker instanceof FieldMarker) {\n\t\t\t\t\tthrow new Error('Invalid marker')\n\t\t\t\t}\n\t\t\t\tmarker = relationMarker\n\t\t\t}\n\t\t\treturn marker\n\t\t}, [connectAt, list])\n\n\t\toptions ??= optionsMarker.environment.getSubTreeNode().entity.name\n\n\t\tconst selectedEntities = useMemo(() => Array.from(list).map((it: EntityAccessor) => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\t\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\t\tif (action === 'toggle') {\n\t\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t\t}\n\t\t\tif (action === 'unselect' && isSelected) {\n\t\t\t\tArray.from(list).find((it: EntityAccessor) => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\t\tonUnselect?.(entity)\n\t\t\t} else if (action === 'select' && !isSelected) {\n\t\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\t\tonSelect?.(entity)\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\t\treturn selectedEntities.includes(entity.id)\n\t\t}, [selectedEntities])\n\n\t\treturn (\n\t\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t\t</Repeater>\n\t\t)\n\t},\n\t({ children, field, sortableBy, connectAt }) => {\n\t\treturn (\n\t\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>\n\t\t\t\t<HasOne field={connectAt} expectedMutation=\"connectOrDisconnect\">\n\t\t\t\t\t{children}\n\t\t\t\t</HasOne>\n\t\t\t</Repeater>\n\t\t)\n\t},\n)\n"],"names":["isSelected","this"],"mappings":"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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactUtils = require("@contember/react-utils");
|
|
4
|
+
const _SelectCurrentEntitiesContext = reactUtils.createRequiredContext("SelectCurrentEntitiesContext");
|
|
5
|
+
const SelectCurrentEntitiesContext = _SelectCurrentEntitiesContext[0];
|
|
6
|
+
const useSelectCurrentEntities = _SelectCurrentEntitiesContext[1];
|
|
7
|
+
const _SelectIsSelectedContext = reactUtils.createRequiredContext("SelectIsSelectedContext");
|
|
8
|
+
const SelectIsSelectedContext = _SelectIsSelectedContext[0];
|
|
9
|
+
const useSelectIsSelected = _SelectIsSelectedContext[1];
|
|
10
|
+
const _SelectHandleSelectContext = reactUtils.createRequiredContext("SelectHandleSelectContext");
|
|
11
|
+
const SelectHandleSelectContext = _SelectHandleSelectContext[0];
|
|
12
|
+
const useSelectHandleSelect = _SelectHandleSelectContext[1];
|
|
13
|
+
const _SelectOptionsContext = reactUtils.createRequiredContext("SelectOptionsContext");
|
|
14
|
+
const SelectOptionsContext = _SelectOptionsContext[0];
|
|
15
|
+
const useSelectOptions = _SelectOptionsContext[1];
|
|
16
|
+
exports.SelectCurrentEntitiesContext = SelectCurrentEntitiesContext;
|
|
17
|
+
exports.SelectHandleSelectContext = SelectHandleSelectContext;
|
|
18
|
+
exports.SelectIsSelectedContext = SelectIsSelectedContext;
|
|
19
|
+
exports.SelectOptionsContext = SelectOptionsContext;
|
|
20
|
+
exports.useSelectCurrentEntities = useSelectCurrentEntities;
|
|
21
|
+
exports.useSelectHandleSelect = useSelectHandleSelect;
|
|
22
|
+
exports.useSelectIsSelected = useSelectIsSelected;
|
|
23
|
+
exports.useSelectOptions = useSelectOptions;
|
|
24
|
+
//# sourceMappingURL=contexts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.cjs","sources":["../../../../packages/react-select/src/contexts.ts"],"sourcesContent":["import { createRequiredContext } from '@contember/react-utils'\nimport { EntityAccessor, SugaredQualifiedEntityList } from '@contember/react-binding'\nimport { DataViewFilterHandler, TextFilterArtifacts } from '@contember/react-dataview'\n\nconst _SelectCurrentEntitiesContext = createRequiredContext<EntityAccessor[]>('SelectCurrentEntitiesContext')\n/** @internal */\nexport const SelectCurrentEntitiesContext = _SelectCurrentEntitiesContext[0]\nexport const useSelectCurrentEntities = _SelectCurrentEntitiesContext[1]\n\nconst _SelectIsSelectedContext = createRequiredContext<(entity: EntityAccessor) => boolean>('SelectIsSelectedContext')\n/** @internal */\nexport const SelectIsSelectedContext = _SelectIsSelectedContext[0]\nexport const useSelectIsSelected = _SelectIsSelectedContext[1]\n\nexport type SelectHandler = (entity: EntityAccessor, action?: 'select' | 'unselect' | 'toggle') => void\nconst _SelectHandleSelectContext = createRequiredContext<SelectHandler>('SelectHandleSelectContext')\n/** @internal */\nexport const SelectHandleSelectContext = _SelectHandleSelectContext[0]\nexport const useSelectHandleSelect = _SelectHandleSelectContext[1]\n\nconst _SelectOptionsContext = createRequiredContext<SugaredQualifiedEntityList['entities']>('SelectOptionsContext')\n/** @internal */\nexport const SelectOptionsContext = _SelectOptionsContext[0]\nexport const useSelectOptions = _SelectOptionsContext[1]\n"],"names":["createRequiredContext"],"mappings":";;;AAIA,MAAM,gCAAgCA,WAAAA,sBAAwC,8BAA8B;AAErG,MAAM,+BAA+B,8BAA8B,CAAC;AACpE,MAAM,2BAA2B,8BAA8B,CAAC;AAEvE,MAAM,2BAA2BA,WAAAA,sBAA2D,yBAAyB;AAE9G,MAAM,0BAA0B,yBAAyB,CAAC;AAC1D,MAAM,sBAAsB,yBAAyB,CAAC;AAG7D,MAAM,6BAA6BA,WAAAA,sBAAqC,2BAA2B;AAE5F,MAAM,4BAA4B,2BAA2B,CAAC;AAC9D,MAAM,wBAAwB,2BAA2B,CAAC;AAEjE,MAAM,wBAAwBA,WAAAA,sBAA8D,sBAAsB;AAE3G,MAAM,uBAAuB,sBAAsB,CAAC;AACpD,MAAM,mBAAmB,sBAAsB,CAAC;;;;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRequiredContext } from "@contember/react-utils";
|
|
2
|
+
const _SelectCurrentEntitiesContext = createRequiredContext("SelectCurrentEntitiesContext");
|
|
3
|
+
const SelectCurrentEntitiesContext = _SelectCurrentEntitiesContext[0];
|
|
4
|
+
const useSelectCurrentEntities = _SelectCurrentEntitiesContext[1];
|
|
5
|
+
const _SelectIsSelectedContext = createRequiredContext("SelectIsSelectedContext");
|
|
6
|
+
const SelectIsSelectedContext = _SelectIsSelectedContext[0];
|
|
7
|
+
const useSelectIsSelected = _SelectIsSelectedContext[1];
|
|
8
|
+
const _SelectHandleSelectContext = createRequiredContext("SelectHandleSelectContext");
|
|
9
|
+
const SelectHandleSelectContext = _SelectHandleSelectContext[0];
|
|
10
|
+
const useSelectHandleSelect = _SelectHandleSelectContext[1];
|
|
11
|
+
const _SelectOptionsContext = createRequiredContext("SelectOptionsContext");
|
|
12
|
+
const SelectOptionsContext = _SelectOptionsContext[0];
|
|
13
|
+
const useSelectOptions = _SelectOptionsContext[1];
|
|
14
|
+
export {
|
|
15
|
+
SelectCurrentEntitiesContext,
|
|
16
|
+
SelectHandleSelectContext,
|
|
17
|
+
SelectIsSelectedContext,
|
|
18
|
+
SelectOptionsContext,
|
|
19
|
+
useSelectCurrentEntities,
|
|
20
|
+
useSelectHandleSelect,
|
|
21
|
+
useSelectIsSelected,
|
|
22
|
+
useSelectOptions
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=contexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.js","sources":["../../../../packages/react-select/src/contexts.ts"],"sourcesContent":["import { createRequiredContext } from '@contember/react-utils'\nimport { EntityAccessor, SugaredQualifiedEntityList } from '@contember/react-binding'\nimport { DataViewFilterHandler, TextFilterArtifacts } from '@contember/react-dataview'\n\nconst _SelectCurrentEntitiesContext = createRequiredContext<EntityAccessor[]>('SelectCurrentEntitiesContext')\n/** @internal */\nexport const SelectCurrentEntitiesContext = _SelectCurrentEntitiesContext[0]\nexport const useSelectCurrentEntities = _SelectCurrentEntitiesContext[1]\n\nconst _SelectIsSelectedContext = createRequiredContext<(entity: EntityAccessor) => boolean>('SelectIsSelectedContext')\n/** @internal */\nexport const SelectIsSelectedContext = _SelectIsSelectedContext[0]\nexport const useSelectIsSelected = _SelectIsSelectedContext[1]\n\nexport type SelectHandler = (entity: EntityAccessor, action?: 'select' | 'unselect' | 'toggle') => void\nconst _SelectHandleSelectContext = createRequiredContext<SelectHandler>('SelectHandleSelectContext')\n/** @internal */\nexport const SelectHandleSelectContext = _SelectHandleSelectContext[0]\nexport const useSelectHandleSelect = _SelectHandleSelectContext[1]\n\nconst _SelectOptionsContext = createRequiredContext<SugaredQualifiedEntityList['entities']>('SelectOptionsContext')\n/** @internal */\nexport const SelectOptionsContext = _SelectOptionsContext[0]\nexport const useSelectOptions = _SelectOptionsContext[1]\n"],"names":[],"mappings":";AAIA,MAAM,gCAAgC,sBAAwC,8BAA8B;AAErG,MAAM,+BAA+B,8BAA8B,CAAC;AACpE,MAAM,2BAA2B,8BAA8B,CAAC;AAEvE,MAAM,2BAA2B,sBAA2D,yBAAyB;AAE9G,MAAM,0BAA0B,yBAAyB,CAAC;AAC1D,MAAM,sBAAsB,yBAAyB,CAAC;AAG7D,MAAM,6BAA6B,sBAAqC,2BAA2B;AAE5F,MAAM,4BAA4B,2BAA2B,CAAC;AAC9D,MAAM,wBAAwB,2BAA2B,CAAC;AAEjE,MAAM,wBAAwB,sBAA8D,sBAAsB;AAE3G,MAAM,uBAAuB,sBAAsB,CAAC;AACpD,MAAM,mBAAmB,sBAAsB,CAAC;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const contexts = require("./src/contexts.cjs");
|
|
4
|
+
const MultiSelect = require("./src/components/MultiSelect.cjs");
|
|
5
|
+
const Select = require("./src/components/Select.cjs");
|
|
6
|
+
const SelectDataView = require("./src/components/SelectDataView.cjs");
|
|
7
|
+
const SelectEachItem = require("./src/components/SelectEachItem.cjs");
|
|
8
|
+
const SelectItemTrigger = require("./src/components/SelectItemTrigger.cjs");
|
|
9
|
+
const SelectNewItem = require("./src/components/SelectNewItem.cjs");
|
|
10
|
+
const SelectOption = require("./src/components/SelectOption.cjs");
|
|
11
|
+
const SelectPlaceholder = require("./src/components/SelectPlaceholder.cjs");
|
|
12
|
+
const SortableMultiSelect = require("./src/components/SortableMultiSelect.cjs");
|
|
13
|
+
exports.SelectCurrentEntitiesContext = contexts.SelectCurrentEntitiesContext;
|
|
14
|
+
exports.SelectHandleSelectContext = contexts.SelectHandleSelectContext;
|
|
15
|
+
exports.SelectIsSelectedContext = contexts.SelectIsSelectedContext;
|
|
16
|
+
exports.SelectOptionsContext = contexts.SelectOptionsContext;
|
|
17
|
+
exports.useSelectCurrentEntities = contexts.useSelectCurrentEntities;
|
|
18
|
+
exports.useSelectHandleSelect = contexts.useSelectHandleSelect;
|
|
19
|
+
exports.useSelectIsSelected = contexts.useSelectIsSelected;
|
|
20
|
+
exports.useSelectOptions = contexts.useSelectOptions;
|
|
21
|
+
exports.MultiSelect = MultiSelect.MultiSelect;
|
|
22
|
+
exports.Select = Select.Select;
|
|
23
|
+
exports.SelectDataView = SelectDataView.SelectDataView;
|
|
24
|
+
exports.SelectEachValue = SelectEachItem.SelectEachValue;
|
|
25
|
+
exports.SelectItemTrigger = SelectItemTrigger.SelectItemTrigger;
|
|
26
|
+
exports.SelectNewItem = SelectNewItem.SelectNewItem;
|
|
27
|
+
exports.SelectOption = SelectOption.SelectOption;
|
|
28
|
+
exports.SelectPlaceholder = SelectPlaceholder.SelectPlaceholder;
|
|
29
|
+
exports.SortableMultiSelect = SortableMultiSelect.SortableMultiSelect;
|
|
30
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SelectCurrentEntitiesContext, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext, useSelectCurrentEntities, useSelectHandleSelect, useSelectIsSelected, useSelectOptions } from "./src/contexts.js";
|
|
2
|
+
import { MultiSelect } from "./src/components/MultiSelect.js";
|
|
3
|
+
import { Select } from "./src/components/Select.js";
|
|
4
|
+
import { SelectDataView } from "./src/components/SelectDataView.js";
|
|
5
|
+
import { SelectEachValue } from "./src/components/SelectEachItem.js";
|
|
6
|
+
import { SelectItemTrigger } from "./src/components/SelectItemTrigger.js";
|
|
7
|
+
import { SelectNewItem } from "./src/components/SelectNewItem.js";
|
|
8
|
+
import { SelectOption } from "./src/components/SelectOption.js";
|
|
9
|
+
import { SelectPlaceholder } from "./src/components/SelectPlaceholder.js";
|
|
10
|
+
import { SortableMultiSelect } from "./src/components/SortableMultiSelect.js";
|
|
11
|
+
export {
|
|
12
|
+
MultiSelect,
|
|
13
|
+
Select,
|
|
14
|
+
SelectCurrentEntitiesContext,
|
|
15
|
+
SelectDataView,
|
|
16
|
+
SelectEachValue,
|
|
17
|
+
SelectHandleSelectContext,
|
|
18
|
+
SelectIsSelectedContext,
|
|
19
|
+
SelectItemTrigger,
|
|
20
|
+
SelectNewItem,
|
|
21
|
+
SelectOption,
|
|
22
|
+
SelectOptionsContext,
|
|
23
|
+
SelectPlaceholder,
|
|
24
|
+
SortableMultiSelect,
|
|
25
|
+
useSelectCurrentEntities,
|
|
26
|
+
useSelectHandleSelect,
|
|
27
|
+
useSelectIsSelected,
|
|
28
|
+
useSelectOptions
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const contexts = require("../contexts.cjs");
|
|
6
|
+
const reactBinding = require("@contember/react-binding");
|
|
7
|
+
const reactUtils = require("@contember/react-utils");
|
|
8
|
+
const MultiSelect = reactBinding.Component(({ field, children, options, onSelect, onUnselect }) => {
|
|
9
|
+
const entities = reactBinding.useEntityList({ field });
|
|
10
|
+
options ?? (options = entities.name);
|
|
11
|
+
const entitiesArr = React.useMemo(() => Array.from(entities), [entities]);
|
|
12
|
+
const selectedEntities = React.useMemo(() => Array.from(entities).map((it) => it.id), [entities]);
|
|
13
|
+
const handler = reactUtils.useReferentiallyStableCallback((entity, action = "toggle") => {
|
|
14
|
+
const isSelected2 = selectedEntities.includes(entity.id);
|
|
15
|
+
if (action === "toggle") {
|
|
16
|
+
action = isSelected2 ? "unselect" : "select";
|
|
17
|
+
}
|
|
18
|
+
if (action === "unselect" && isSelected2) {
|
|
19
|
+
entities.disconnectEntity(entity);
|
|
20
|
+
onUnselect?.(entity);
|
|
21
|
+
} else if (action === "select" && !isSelected2) {
|
|
22
|
+
entities.connectEntity(entity);
|
|
23
|
+
onSelect?.(entity);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const isSelected = React.useCallback((entity) => {
|
|
27
|
+
return selectedEntities.includes(entity.id);
|
|
28
|
+
}, [selectedEntities]);
|
|
29
|
+
return /* @__PURE__ */ jsxRuntime.jsx(contexts.SelectCurrentEntitiesContext.Provider, { value: entitiesArr, children: /* @__PURE__ */ jsxRuntime.jsx(contexts.SelectIsSelectedContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(contexts.SelectHandleSelectContext.Provider, { value: handler, children: /* @__PURE__ */ jsxRuntime.jsx(contexts.SelectOptionsContext.Provider, { value: options, children }) }) }) });
|
|
30
|
+
}, ({ field, children }) => {
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactBinding.HasMany, { field, expectedMutation: "connectOrDisconnect", children });
|
|
32
|
+
});
|
|
33
|
+
exports.MultiSelect = MultiSelect;
|
|
34
|
+
//# sourceMappingURL=MultiSelect.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelect.cjs","sources":["../../../../../packages/react-select/src/components/MultiSelect.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport { Component, EntityAccessor, HasMany, SugaredQualifiedEntityList, SugaredRelativeEntityList, useEntityList } from '@contember/react-binding'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\nimport { SelectEvents } from '../types'\n\nexport type MultiSelectProps =\n\t& {\n\t\tchildren: ReactNode\n\t\tfield: SugaredRelativeEntityList['field']\n\t\toptions?: SugaredQualifiedEntityList['entities']\n\t}\n\t& SelectEvents\n\nexport const MultiSelect = Component(({ field, children, options, onSelect, onUnselect }: MultiSelectProps) => {\n\tconst entities = useEntityList({ field })\n\toptions ??= entities.name\n\tconst entitiesArr = useMemo(() => Array.from(entities), [entities])\n\tconst selectedEntities = useMemo(() => Array.from(entities).map((it: EntityAccessor) => it.id), [entities])\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\tentities.disconnectEntity(entity)\n\t\t\tonUnselect?.(entity)\n\t\t} else if (action === 'select' && !isSelected) {\n\t\t\tentities.connectEntity(entity)\n\t\t\tonSelect?.(entity)\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<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t</SelectIsSelectedContext.Provider>\n\t\t</SelectCurrentEntitiesContext.Provider>\n\t)\n}, ({ field, children }) => {\n\treturn (\n\t\t<HasMany field={field} expectedMutation=\"connectOrDisconnect\">\n\t\t\t{children}\n\t\t</HasMany>\n\t)\n})\n"],"names":["Component","useEntityList","useMemo","useReferentiallyStableCallback","isSelected","useCallback","jsx","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","HasMany"],"mappings":";;;;;;;AAcO,MAAM,cAAcA,aAAAA,UAAU,CAAC,EAAE,OAAO,UAAU,SAAS,UAAU,iBAAmC;AAC9G,QAAM,WAAWC,aAAAA,cAAc,EAAE,OAAO;AACxC,cAAA,UAAY,SAAS;AACrB,QAAM,cAAcC,MAAAA,QAAQ,MAAM,MAAM,KAAK,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAClE,QAAM,mBAAmBA,MAAAA,QAAQ,MAAM,MAAM,KAAK,QAAQ,EAAE,IAAI,CAAC,OAAuB,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC;AAE1G,QAAM,UAAUC,WAAAA,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,UAAMC,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,QAAI,WAAW,UAAU;AACxB,eAASA,cAAa,aAAa;AAAA,IACpC;AACA,QAAI,WAAW,cAAcA,aAAY;AACxC,eAAS,iBAAiB,MAAM;AAChC,mBAAa,MAAM;AAAA,IACpB,WAAW,WAAW,YAAY,CAACA,aAAY;AAC9C,eAAS,cAAc,MAAM;AAC7B,iBAAW,MAAM;AAAA,IAClB;AAAA,EACD,CAAC;AACD,QAAM,aAAaC,kBAAY,CAAC,WAA2B;AAC1D,WAAO,iBAAiB,SAAS,OAAO,EAAE;AAAA,EAC3C,GAAG,CAAC,gBAAgB,CAAC;AAErB,SACCC,2BAAAA,IAACC,SAAAA,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAAD,2BAAAA,IAACE,SAAAA,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,UAAAF,2BAAAA,IAACG,SAAAA,0BAA0B,UAA1B,EAAmC,OAAO,SAC1C,UAAAH,2BAAAA,IAACI,SAAAA,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SAAA,CACF,EAAA,CACD,EAAA,CACD,EAAA,CACD;AAEF,GAAG,CAAC,EAAE,OAAO,eAAe;AAC3B,SACCJ,2BAAAA,IAACK,aAAAA,SAAA,EAAQ,OAAc,kBAAiB,uBACtC,UACF;AAEF,CAAC;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useCallback } from "react";
|
|
3
|
+
import { SelectCurrentEntitiesContext, SelectIsSelectedContext, SelectHandleSelectContext, SelectOptionsContext } from "../contexts.js";
|
|
4
|
+
import { Component, useEntityList, HasMany } from "@contember/react-binding";
|
|
5
|
+
import { useReferentiallyStableCallback } from "@contember/react-utils";
|
|
6
|
+
const MultiSelect = Component(({ field, children, options, onSelect, onUnselect }) => {
|
|
7
|
+
const entities = useEntityList({ field });
|
|
8
|
+
options ?? (options = entities.name);
|
|
9
|
+
const entitiesArr = useMemo(() => Array.from(entities), [entities]);
|
|
10
|
+
const selectedEntities = useMemo(() => Array.from(entities).map((it) => it.id), [entities]);
|
|
11
|
+
const handler = useReferentiallyStableCallback((entity, action = "toggle") => {
|
|
12
|
+
const isSelected2 = selectedEntities.includes(entity.id);
|
|
13
|
+
if (action === "toggle") {
|
|
14
|
+
action = isSelected2 ? "unselect" : "select";
|
|
15
|
+
}
|
|
16
|
+
if (action === "unselect" && isSelected2) {
|
|
17
|
+
entities.disconnectEntity(entity);
|
|
18
|
+
onUnselect?.(entity);
|
|
19
|
+
} else if (action === "select" && !isSelected2) {
|
|
20
|
+
entities.connectEntity(entity);
|
|
21
|
+
onSelect?.(entity);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const isSelected = useCallback((entity) => {
|
|
25
|
+
return selectedEntities.includes(entity.id);
|
|
26
|
+
}, [selectedEntities]);
|
|
27
|
+
return /* @__PURE__ */ jsx(SelectCurrentEntitiesContext.Provider, { value: entitiesArr, children: /* @__PURE__ */ jsx(SelectIsSelectedContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsx(SelectHandleSelectContext.Provider, { value: handler, children: /* @__PURE__ */ jsx(SelectOptionsContext.Provider, { value: options, children }) }) }) });
|
|
28
|
+
}, ({ field, children }) => {
|
|
29
|
+
return /* @__PURE__ */ jsx(HasMany, { field, expectedMutation: "connectOrDisconnect", children });
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
MultiSelect
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=MultiSelect.js.map
|