@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,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,54 @@
|
|
|
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 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__ */ 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, {
|
|
30
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
31
|
+
lineNumber: 42,
|
|
32
|
+
columnNumber: 6
|
|
33
|
+
}, void 0) }, void 0, false, {
|
|
34
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
35
|
+
lineNumber: 41,
|
|
36
|
+
columnNumber: 5
|
|
37
|
+
}, void 0) }, void 0, false, {
|
|
38
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
39
|
+
lineNumber: 40,
|
|
40
|
+
columnNumber: 4
|
|
41
|
+
}, void 0) }, void 0, false, {
|
|
42
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
43
|
+
lineNumber: 39,
|
|
44
|
+
columnNumber: 3
|
|
45
|
+
}, void 0);
|
|
46
|
+
}, ({ field, children }) => {
|
|
47
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.HasMany, { field, expectedMutation: "connectOrDisconnect", children }, void 0, false, {
|
|
48
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
49
|
+
lineNumber: 51,
|
|
50
|
+
columnNumber: 3
|
|
51
|
+
}, void 0);
|
|
52
|
+
});
|
|
53
|
+
exports.MultiSelect = MultiSelect;
|
|
54
|
+
//# 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","jsxDEV","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","this","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,8BAAAA,OAACC,SAAAA,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAAD,8BAAAA,OAACE,SAAAA,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,+CAACC,SAAAA,0BAA0B,UAA1B,EAAmC,OAAO,SAC1C,UAAAH,8BAAAA,OAACI,SAAAA,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,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,EAAA,GAPD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA;AAEF,GAAG,CAAC,EAAE,OAAO,eAAe;AAC3B,SACCL,8BAAAA,OAACM,sBAAA,EAAQ,OAAc,kBAAiB,uBACtC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAD,MAEA;AAEF,CAAC;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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, 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__ */ 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, {
|
|
28
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
29
|
+
lineNumber: 42,
|
|
30
|
+
columnNumber: 6
|
|
31
|
+
}, void 0) }, void 0, false, {
|
|
32
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
33
|
+
lineNumber: 41,
|
|
34
|
+
columnNumber: 5
|
|
35
|
+
}, void 0) }, void 0, false, {
|
|
36
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
37
|
+
lineNumber: 40,
|
|
38
|
+
columnNumber: 4
|
|
39
|
+
}, void 0) }, void 0, false, {
|
|
40
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
41
|
+
lineNumber: 39,
|
|
42
|
+
columnNumber: 3
|
|
43
|
+
}, void 0);
|
|
44
|
+
}, ({ field, children }) => {
|
|
45
|
+
return /* @__PURE__ */ jsxDEV(HasMany, { field, expectedMutation: "connectOrDisconnect", children }, void 0, false, {
|
|
46
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/MultiSelect.tsx",
|
|
47
|
+
lineNumber: 51,
|
|
48
|
+
columnNumber: 3
|
|
49
|
+
}, void 0);
|
|
50
|
+
});
|
|
51
|
+
export {
|
|
52
|
+
MultiSelect
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=MultiSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelect.js","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":["isSelected","this"],"mappings":";;;;;AAcO,MAAM,cAAc,UAAU,CAAC,EAAE,OAAO,UAAU,SAAS,UAAU,iBAAmC;AAC9G,QAAM,WAAW,cAAc,EAAE,OAAO;AACxC,cAAA,UAAY,SAAS;AACrB,QAAM,cAAc,QAAQ,MAAM,MAAM,KAAK,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAClE,QAAM,mBAAmB,QAAQ,MAAM,MAAM,KAAK,QAAQ,EAAE,IAAI,CAAC,OAAuB,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC;AAE1G,QAAM,UAAU,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,UAAMA,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,aAAa,YAAY,CAAC,WAA2B;AAC1D,WAAO,iBAAiB,SAAS,OAAO,EAAE;AAAA,EAC3C,GAAG,CAAC,gBAAgB,CAAC;AAErB,SACC,uBAAC,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAA,uBAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,iCAAC,0BAA0B,UAA1B,EAAmC,OAAO,SAC1C,UAAA,uBAAC,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,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,EAAA,GAPD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA;AAEF,GAAG,CAAC,EAAE,OAAO,eAAe;AAC3B,SACC,uBAAC,SAAA,EAAQ,OAAc,kBAAiB,uBACtC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA;AAEF,CAAC;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 Select = reactBinding.Component(({ field, children, onUnselect, onSelect, options }) => {
|
|
9
|
+
const entity = reactBinding.useEntity();
|
|
10
|
+
const selectedEntity = entity.getEntity({ field });
|
|
11
|
+
options ?? (options = selectedEntity.name);
|
|
12
|
+
const entityExists = selectedEntity.existsOnServer || selectedEntity.hasUnpersistedChanges;
|
|
13
|
+
const entitiesArr = React.useMemo(() => entityExists ? [selectedEntity] : [], [entityExists, selectedEntity]);
|
|
14
|
+
const handleSelect = reactUtils.useReferentiallyStableCallback((selected, action = "toggle") => {
|
|
15
|
+
if (action === "toggle") {
|
|
16
|
+
action = selected.id === selectedEntity.id ? "unselect" : "select";
|
|
17
|
+
}
|
|
18
|
+
if (action === "unselect") {
|
|
19
|
+
entity.disconnectEntityAtField({ field });
|
|
20
|
+
onUnselect?.(selected);
|
|
21
|
+
} else if (action === "select") {
|
|
22
|
+
entity.connectEntityAtField({ field }, selected);
|
|
23
|
+
onSelect?.(selected);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const isSelected = React.useCallback((entity2) => entity2.id === selectedEntity.id, [selectedEntity.id]);
|
|
27
|
+
return /* @__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: handleSelect, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.SelectOptionsContext.Provider, { value: options, children }, void 0, false, {
|
|
28
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
29
|
+
lineNumber: 42,
|
|
30
|
+
columnNumber: 6
|
|
31
|
+
}, void 0) }, void 0, false, {
|
|
32
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
33
|
+
lineNumber: 41,
|
|
34
|
+
columnNumber: 5
|
|
35
|
+
}, void 0) }, void 0, false, {
|
|
36
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
37
|
+
lineNumber: 40,
|
|
38
|
+
columnNumber: 4
|
|
39
|
+
}, void 0) }, void 0, false, {
|
|
40
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
41
|
+
lineNumber: 39,
|
|
42
|
+
columnNumber: 3
|
|
43
|
+
}, void 0);
|
|
44
|
+
}, ({ field, children, isNonbearing }) => {
|
|
45
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.HasOne, { field, expectedMutation: "connectOrDisconnect", isNonbearing, children }, void 0, false, {
|
|
46
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
47
|
+
lineNumber: 51,
|
|
48
|
+
columnNumber: 3
|
|
49
|
+
}, void 0);
|
|
50
|
+
});
|
|
51
|
+
exports.Select = Select;
|
|
52
|
+
//# sourceMappingURL=Select.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.cjs","sources":["../../../../../packages/react-select/src/components/Select.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport { Component, EntityAccessor, HasOne, SugaredQualifiedEntityList, SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\nimport { SelectEvents } from '../types'\n\nexport type SelectProps =\n\t& {\n\t\tchildren: ReactNode\n\t\tfield: SugaredRelativeSingleEntity['field']\n\t\toptions?: SugaredQualifiedEntityList['entities']\n\t\tisNonbearing?: boolean\n\t}\n\t& SelectEvents\n\nexport const Select = Component(({ field, children, onUnselect, onSelect, options }: SelectProps) => {\n\tconst entity = useEntity()\n\tconst selectedEntity = entity.getEntity({ field })\n\toptions ??= selectedEntity.name\n\n\tconst entityExists = selectedEntity.existsOnServer || selectedEntity.hasUnpersistedChanges\n\tconst entitiesArr = useMemo(() => entityExists ? [selectedEntity] : [], [entityExists, selectedEntity])\n\n\tconst handleSelect = useReferentiallyStableCallback<SelectHandler>((selected, action = 'toggle') => {\n\t\tif (action === 'toggle') {\n\t\t\taction = selected.id === selectedEntity.id ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect') {\n\t\t\tentity.disconnectEntityAtField({ field })\n\t\t\tonUnselect?.(selected)\n\t\t} else if (action === 'select') {\n\t\t\tentity.connectEntityAtField({ field }, selected)\n\t\t\tonSelect?.(selected)\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => entity.id === selectedEntity.id, [selectedEntity.id])\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={handleSelect}>\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, isNonbearing }) => {\n\treturn (\n\t\t<HasOne field={field} expectedMutation=\"connectOrDisconnect\" isNonbearing={isNonbearing}>\n\t\t\t{children}\n\t\t</HasOne>\n\t)\n})\n"],"names":["Component","useEntity","useMemo","useReferentiallyStableCallback","useCallback","entity","jsxDEV","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","this","HasOne"],"mappings":";;;;;;;AAeO,MAAM,SAASA,aAAAA,UAAU,CAAC,EAAE,OAAO,UAAU,YAAY,UAAU,cAA2B;AACpG,QAAM,SAASC,aAAAA,UAAA;AACf,QAAM,iBAAiB,OAAO,UAAU,EAAE,OAAO;AACjD,cAAA,UAAY,eAAe;AAE3B,QAAM,eAAe,eAAe,kBAAkB,eAAe;AACrE,QAAM,cAAcC,cAAQ,MAAM,eAAe,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,cAAc,CAAC;AAEtG,QAAM,eAAeC,WAAAA,+BAA8C,CAAC,UAAU,SAAS,aAAa;AACnG,QAAI,WAAW,UAAU;AACxB,eAAS,SAAS,OAAO,eAAe,KAAK,aAAa;AAAA,IAC3D;AACA,QAAI,WAAW,YAAY;AAC1B,aAAO,wBAAwB,EAAE,OAAO;AACxC,mBAAa,QAAQ;AAAA,IACtB,WAAW,WAAW,UAAU;AAC/B,aAAO,qBAAqB,EAAE,MAAA,GAAS,QAAQ;AAC/C,iBAAW,QAAQ;AAAA,IACpB;AAAA,EACD,CAAC;AACD,QAAM,aAAaC,MAAAA,YAAY,CAACC,YAA2BA,QAAO,OAAO,eAAe,IAAI,CAAC,eAAe,EAAE,CAAC;AAE/G,SACCC,8BAAAA,OAACC,SAAAA,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAAD,8BAAAA,OAACE,SAAAA,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,+CAACC,SAAAA,0BAA0B,UAA1B,EAAmC,OAAO,cAC1C,UAAAH,8BAAAA,OAACI,SAAAA,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,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,EAAA,GAPD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA;AAEF,GAAG,CAAC,EAAE,OAAO,UAAU,mBAAmB;AACzC,8CACEC,aAAAA,QAAA,EAAO,OAAc,kBAAiB,uBAAsB,cAC3D,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAD,MAEA;AAEF,CAAC;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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, useEntity, HasOne } from "@contember/react-binding";
|
|
5
|
+
import { useReferentiallyStableCallback } from "@contember/react-utils";
|
|
6
|
+
const Select = Component(({ field, children, onUnselect, onSelect, options }) => {
|
|
7
|
+
const entity = useEntity();
|
|
8
|
+
const selectedEntity = entity.getEntity({ field });
|
|
9
|
+
options ?? (options = selectedEntity.name);
|
|
10
|
+
const entityExists = selectedEntity.existsOnServer || selectedEntity.hasUnpersistedChanges;
|
|
11
|
+
const entitiesArr = useMemo(() => entityExists ? [selectedEntity] : [], [entityExists, selectedEntity]);
|
|
12
|
+
const handleSelect = useReferentiallyStableCallback((selected, action = "toggle") => {
|
|
13
|
+
if (action === "toggle") {
|
|
14
|
+
action = selected.id === selectedEntity.id ? "unselect" : "select";
|
|
15
|
+
}
|
|
16
|
+
if (action === "unselect") {
|
|
17
|
+
entity.disconnectEntityAtField({ field });
|
|
18
|
+
onUnselect?.(selected);
|
|
19
|
+
} else if (action === "select") {
|
|
20
|
+
entity.connectEntityAtField({ field }, selected);
|
|
21
|
+
onSelect?.(selected);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const isSelected = useCallback((entity2) => entity2.id === selectedEntity.id, [selectedEntity.id]);
|
|
25
|
+
return /* @__PURE__ */ jsxDEV(SelectCurrentEntitiesContext.Provider, { value: entitiesArr, children: /* @__PURE__ */ jsxDEV(SelectIsSelectedContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxDEV(SelectHandleSelectContext.Provider, { value: handleSelect, children: /* @__PURE__ */ jsxDEV(SelectOptionsContext.Provider, { value: options, children }, void 0, false, {
|
|
26
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
27
|
+
lineNumber: 42,
|
|
28
|
+
columnNumber: 6
|
|
29
|
+
}, void 0) }, void 0, false, {
|
|
30
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
31
|
+
lineNumber: 41,
|
|
32
|
+
columnNumber: 5
|
|
33
|
+
}, void 0) }, void 0, false, {
|
|
34
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
35
|
+
lineNumber: 40,
|
|
36
|
+
columnNumber: 4
|
|
37
|
+
}, void 0) }, void 0, false, {
|
|
38
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
39
|
+
lineNumber: 39,
|
|
40
|
+
columnNumber: 3
|
|
41
|
+
}, void 0);
|
|
42
|
+
}, ({ field, children, isNonbearing }) => {
|
|
43
|
+
return /* @__PURE__ */ jsxDEV(HasOne, { field, expectedMutation: "connectOrDisconnect", isNonbearing, children }, void 0, false, {
|
|
44
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/Select.tsx",
|
|
45
|
+
lineNumber: 51,
|
|
46
|
+
columnNumber: 3
|
|
47
|
+
}, void 0);
|
|
48
|
+
});
|
|
49
|
+
export {
|
|
50
|
+
Select
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=Select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../../packages/react-select/src/components/Select.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo } from 'react'\nimport { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext, SelectIsSelectedContext, SelectOptionsContext } from '../contexts'\nimport { Component, EntityAccessor, HasOne, SugaredQualifiedEntityList, SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\nimport { SelectEvents } from '../types'\n\nexport type SelectProps =\n\t& {\n\t\tchildren: ReactNode\n\t\tfield: SugaredRelativeSingleEntity['field']\n\t\toptions?: SugaredQualifiedEntityList['entities']\n\t\tisNonbearing?: boolean\n\t}\n\t& SelectEvents\n\nexport const Select = Component(({ field, children, onUnselect, onSelect, options }: SelectProps) => {\n\tconst entity = useEntity()\n\tconst selectedEntity = entity.getEntity({ field })\n\toptions ??= selectedEntity.name\n\n\tconst entityExists = selectedEntity.existsOnServer || selectedEntity.hasUnpersistedChanges\n\tconst entitiesArr = useMemo(() => entityExists ? [selectedEntity] : [], [entityExists, selectedEntity])\n\n\tconst handleSelect = useReferentiallyStableCallback<SelectHandler>((selected, action = 'toggle') => {\n\t\tif (action === 'toggle') {\n\t\t\taction = selected.id === selectedEntity.id ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect') {\n\t\t\tentity.disconnectEntityAtField({ field })\n\t\t\tonUnselect?.(selected)\n\t\t} else if (action === 'select') {\n\t\t\tentity.connectEntityAtField({ field }, selected)\n\t\t\tonSelect?.(selected)\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => entity.id === selectedEntity.id, [selectedEntity.id])\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={handleSelect}>\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, isNonbearing }) => {\n\treturn (\n\t\t<HasOne field={field} expectedMutation=\"connectOrDisconnect\" isNonbearing={isNonbearing}>\n\t\t\t{children}\n\t\t</HasOne>\n\t)\n})\n"],"names":["entity","this"],"mappings":";;;;;AAeO,MAAM,SAAS,UAAU,CAAC,EAAE,OAAO,UAAU,YAAY,UAAU,cAA2B;AACpG,QAAM,SAAS,UAAA;AACf,QAAM,iBAAiB,OAAO,UAAU,EAAE,OAAO;AACjD,cAAA,UAAY,eAAe;AAE3B,QAAM,eAAe,eAAe,kBAAkB,eAAe;AACrE,QAAM,cAAc,QAAQ,MAAM,eAAe,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,cAAc,CAAC;AAEtG,QAAM,eAAe,+BAA8C,CAAC,UAAU,SAAS,aAAa;AACnG,QAAI,WAAW,UAAU;AACxB,eAAS,SAAS,OAAO,eAAe,KAAK,aAAa;AAAA,IAC3D;AACA,QAAI,WAAW,YAAY;AAC1B,aAAO,wBAAwB,EAAE,OAAO;AACxC,mBAAa,QAAQ;AAAA,IACtB,WAAW,WAAW,UAAU;AAC/B,aAAO,qBAAqB,EAAE,MAAA,GAAS,QAAQ;AAC/C,iBAAW,QAAQ;AAAA,IACpB;AAAA,EACD,CAAC;AACD,QAAM,aAAa,YAAY,CAACA,YAA2BA,QAAO,OAAO,eAAe,IAAI,CAAC,eAAe,EAAE,CAAC;AAE/G,SACC,uBAAC,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAA,uBAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,iCAAC,0BAA0B,UAA1B,EAAmC,OAAO,cAC1C,UAAA,uBAAC,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,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,EAAA,GAPD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA;AAEF,GAAG,CAAC,EAAE,OAAO,UAAU,mBAAmB;AACzC,gCACE,QAAA,EAAO,OAAc,kBAAiB,uBAAsB,cAC3D,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA;AAEF,CAAC;"}
|
|
@@ -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 contexts = require("../contexts.cjs");
|
|
5
|
+
const reactDataview = require("@contember/react-dataview");
|
|
6
|
+
const SelectDataView = (props) => {
|
|
7
|
+
const handleSelect = contexts.useSelectHandleSelect();
|
|
8
|
+
const entities = contexts.useSelectOptions();
|
|
9
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
10
|
+
reactDataview.DataView,
|
|
11
|
+
{
|
|
12
|
+
onSelectHighlighted: handleSelect,
|
|
13
|
+
entities,
|
|
14
|
+
filteringStateStorage: "null",
|
|
15
|
+
sortingStateStorage: "null",
|
|
16
|
+
currentPageStateStorage: "null",
|
|
17
|
+
...props
|
|
18
|
+
},
|
|
19
|
+
void 0,
|
|
20
|
+
false,
|
|
21
|
+
{
|
|
22
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectDataView.tsx",
|
|
23
|
+
lineNumber: 16,
|
|
24
|
+
columnNumber: 3
|
|
25
|
+
},
|
|
26
|
+
void 0
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
exports.SelectDataView = SelectDataView;
|
|
30
|
+
//# sourceMappingURL=SelectDataView.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectDataView.cjs","sources":["../../../../../packages/react-select/src/components/SelectDataView.tsx"],"sourcesContent":["import React, { ReactNode, useMemo } from 'react'\nimport { useSelectHandleSelect, useSelectOptions } from '../contexts'\nimport { DataView, DataViewFilterHandlerRegistry, DataViewProps } from '@contember/react-dataview'\n\nexport type SelectDataViewProps =\n\t& Omit<DataViewProps, 'entities'>\n\t& {\n\t\tchildren: ReactNode\n\t}\n\nexport const SelectDataView = (props: SelectDataViewProps) => {\n\tconst handleSelect = useSelectHandleSelect()\n\tconst entities = useSelectOptions()\n\n\treturn (\n\t\t<DataView\n\t\t\tonSelectHighlighted={handleSelect}\n\t\t\tentities={entities}\n\t\t\tfilteringStateStorage=\"null\"\n\t\t\tsortingStateStorage=\"null\"\n\t\t\tcurrentPageStateStorage=\"null\"\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["useSelectHandleSelect","useSelectOptions","jsxDEV","DataView","this"],"mappings":";;;;;AAUO,MAAM,iBAAiB,CAAC,UAA+B;AAC7D,QAAM,eAAeA,SAAAA,sBAAA;AACrB,QAAM,WAAWC,SAAAA,iBAAA;AAEjB,SACCC,8BAAAA;AAAAA,IAACC,cAAAA;AAAAA,IAAA;AAAA,MACA,qBAAqB;AAAA,MACrB;AAAA,MACA,uBAAsB;AAAA,MACtB,qBAAoB;AAAA,MACpB,yBAAwB;AAAA,MACvB,GAAG;AAAA,IAAA;AAAA,IANL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAAA;AASF;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useSelectHandleSelect, useSelectOptions } from "../contexts.js";
|
|
3
|
+
import { DataView } from "@contember/react-dataview";
|
|
4
|
+
const SelectDataView = (props) => {
|
|
5
|
+
const handleSelect = useSelectHandleSelect();
|
|
6
|
+
const entities = useSelectOptions();
|
|
7
|
+
return /* @__PURE__ */ jsxDEV(
|
|
8
|
+
DataView,
|
|
9
|
+
{
|
|
10
|
+
onSelectHighlighted: handleSelect,
|
|
11
|
+
entities,
|
|
12
|
+
filteringStateStorage: "null",
|
|
13
|
+
sortingStateStorage: "null",
|
|
14
|
+
currentPageStateStorage: "null",
|
|
15
|
+
...props
|
|
16
|
+
},
|
|
17
|
+
void 0,
|
|
18
|
+
false,
|
|
19
|
+
{
|
|
20
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectDataView.tsx",
|
|
21
|
+
lineNumber: 16,
|
|
22
|
+
columnNumber: 3
|
|
23
|
+
},
|
|
24
|
+
void 0
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
SelectDataView
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=SelectDataView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectDataView.js","sources":["../../../../../packages/react-select/src/components/SelectDataView.tsx"],"sourcesContent":["import React, { ReactNode, useMemo } from 'react'\nimport { useSelectHandleSelect, useSelectOptions } from '../contexts'\nimport { DataView, DataViewFilterHandlerRegistry, DataViewProps } from '@contember/react-dataview'\n\nexport type SelectDataViewProps =\n\t& Omit<DataViewProps, 'entities'>\n\t& {\n\t\tchildren: ReactNode\n\t}\n\nexport const SelectDataView = (props: SelectDataViewProps) => {\n\tconst handleSelect = useSelectHandleSelect()\n\tconst entities = useSelectOptions()\n\n\treturn (\n\t\t<DataView\n\t\t\tonSelectHighlighted={handleSelect}\n\t\t\tentities={entities}\n\t\t\tfilteringStateStorage=\"null\"\n\t\t\tsortingStateStorage=\"null\"\n\t\t\tcurrentPageStateStorage=\"null\"\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["this"],"mappings":";;;AAUO,MAAM,iBAAiB,CAAC,UAA+B;AAC7D,QAAM,eAAe,sBAAA;AACrB,QAAM,WAAW,iBAAA;AAEjB,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,qBAAqB;AAAA,MACrB;AAAA,MACA,uBAAsB;AAAA,MACtB,qBAAoB;AAAA,MACpB,yBAAwB;AAAA,MACvB,GAAG;AAAA,IAAA;AAAA,IANL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AASF;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 reactBinding = require("@contember/react-binding");
|
|
6
|
+
const SelectEachValue = ({ children }) => {
|
|
7
|
+
const entities = contexts.useSelectCurrentEntities();
|
|
8
|
+
return entities.map((entity) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Entity, { accessor: entity, children }, entity.key, false, {
|
|
9
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectEachItem.tsx",
|
|
10
|
+
lineNumber: 8,
|
|
11
|
+
columnNumber: 3
|
|
12
|
+
}, void 0));
|
|
13
|
+
};
|
|
14
|
+
exports.SelectEachValue = SelectEachValue;
|
|
15
|
+
//# sourceMappingURL=SelectEachItem.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectEachItem.cjs","sources":["../../../../../packages/react-select/src/components/SelectEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useSelectCurrentEntities } from '../contexts'\nimport { Entity } from '@contember/react-binding'\n\nexport const SelectEachValue = ({ children }: { children: ReactNode }) => {\n\tconst entities = useSelectCurrentEntities()\n\treturn entities.map(entity => (\n\t\t<Entity key={entity.key} accessor={entity}>\n\t\t\t{children}\n\t\t</Entity>\n\t))\n}\n"],"names":["useSelectCurrentEntities","jsxDEV","Entity","this"],"mappings":";;;;;AAIO,MAAM,kBAAkB,CAAC,EAAE,eAAwC;AACzE,QAAM,WAAWA,SAAAA,yBAAA;AACjB,SAAO,SAAS,IAAI,CAAA,WACnBC,8BAAAA,OAACC,aAAAA,UAAwB,UAAU,QACjC,SAAA,GADW,OAAO,KAApB,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA,CACA;AACF;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useSelectCurrentEntities } from "../contexts.js";
|
|
3
|
+
import { Entity } from "@contember/react-binding";
|
|
4
|
+
const SelectEachValue = ({ children }) => {
|
|
5
|
+
const entities = useSelectCurrentEntities();
|
|
6
|
+
return entities.map((entity) => /* @__PURE__ */ jsxDEV(Entity, { accessor: entity, children }, entity.key, false, {
|
|
7
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectEachItem.tsx",
|
|
8
|
+
lineNumber: 8,
|
|
9
|
+
columnNumber: 3
|
|
10
|
+
}, void 0));
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
SelectEachValue
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=SelectEachItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectEachItem.js","sources":["../../../../../packages/react-select/src/components/SelectEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useSelectCurrentEntities } from '../contexts'\nimport { Entity } from '@contember/react-binding'\n\nexport const SelectEachValue = ({ children }: { children: ReactNode }) => {\n\tconst entities = useSelectCurrentEntities()\n\treturn entities.map(entity => (\n\t\t<Entity key={entity.key} accessor={entity}>\n\t\t\t{children}\n\t\t</Entity>\n\t))\n}\n"],"names":["this"],"mappings":";;;AAIO,MAAM,kBAAkB,CAAC,EAAE,eAAwC;AACzE,QAAM,WAAW,yBAAA;AACjB,SAAO,SAAS,IAAI,CAAA,WACnB,uBAAC,UAAwB,UAAU,QACjC,SAAA,GADW,OAAO,KAApB,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,CACA;AACF;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 SelectItemTrigger = React.forwardRef(({ action, ...props }, ref) => {
|
|
9
|
+
const handleSelect = contexts.useSelectHandleSelect();
|
|
10
|
+
const entity = reactBinding.useEntity();
|
|
11
|
+
const onClickProp = props.onClick;
|
|
12
|
+
const onClick = React.useCallback((e) => {
|
|
13
|
+
handleSelect?.(entity, action);
|
|
14
|
+
onClickProp?.(e);
|
|
15
|
+
}, [action, entity, handleSelect, onClickProp]);
|
|
16
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactSlot.Slot, { ...props, onClick, ref }, void 0, false, {
|
|
17
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectItemTrigger.tsx",
|
|
18
|
+
lineNumber: 20,
|
|
19
|
+
columnNumber: 9
|
|
20
|
+
}, void 0);
|
|
21
|
+
});
|
|
22
|
+
exports.SelectItemTrigger = SelectItemTrigger;
|
|
23
|
+
//# sourceMappingURL=SelectItemTrigger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectItemTrigger.cjs","sources":["../../../../../packages/react-select/src/components/SelectItemTrigger.tsx"],"sourcesContent":["import React, { forwardRef, ReactElement, useCallback } from 'react'\nimport { useSelectHandleSelect } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useEntity } from '@contember/react-binding'\n\nexport type SelectItemTriggerProps = {\n\tchildren: ReactElement\n\taction?: 'select' | 'unselect' | 'toggle'\n\tonClick?: (event: React.MouseEvent<HTMLElement>) => void\n}\n\nexport const SelectItemTrigger = forwardRef<HTMLElement, SelectItemTriggerProps>(({ action, ...props }: SelectItemTriggerProps, ref) => {\n\tconst handleSelect = useSelectHandleSelect()\n\tconst entity = useEntity()\n\tconst onClickProp = props.onClick\n\tconst onClick = useCallback((e: React.MouseEvent<HTMLElement>) => {\n\t\thandleSelect?.(entity, action)\n\t\tonClickProp?.(e)\n\t}, [action, entity, handleSelect, onClickProp])\n\treturn <Slot {...props} onClick={onClick} ref={ref} />\n})\n"],"names":["forwardRef","useSelectHandleSelect","useEntity","useCallback","jsxDEV","Slot","this"],"mappings":";;;;;;;AAWO,MAAM,oBAAoBA,MAAAA,WAAgD,CAAC,EAAE,QAAQ,GAAG,MAAA,GAAiC,QAAQ;AACvI,QAAM,eAAeC,SAAAA,sBAAA;AACrB,QAAM,SAASC,aAAAA,UAAA;AACf,QAAM,cAAc,MAAM;AAC1B,QAAM,UAAUC,kBAAY,CAAC,MAAqC;AACjE,mBAAe,QAAQ,MAAM;AAC7B,kBAAc,CAAC;AAAA,EAChB,GAAG,CAAC,QAAQ,QAAQ,cAAc,WAAW,CAAC;AAC9C,SAAOC,8BAAAA,OAACC,UAAAA,MAAA,EAAM,GAAG,OAAO,SAAkB,IAAA,GAAnC,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAA6C;AACrD,CAAC;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { forwardRef, useCallback } from "react";
|
|
3
|
+
import { useSelectHandleSelect } from "../contexts.js";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { useEntity } from "@contember/react-binding";
|
|
6
|
+
const SelectItemTrigger = forwardRef(({ action, ...props }, ref) => {
|
|
7
|
+
const handleSelect = useSelectHandleSelect();
|
|
8
|
+
const entity = useEntity();
|
|
9
|
+
const onClickProp = props.onClick;
|
|
10
|
+
const onClick = useCallback((e) => {
|
|
11
|
+
handleSelect?.(entity, action);
|
|
12
|
+
onClickProp?.(e);
|
|
13
|
+
}, [action, entity, handleSelect, onClickProp]);
|
|
14
|
+
return /* @__PURE__ */ jsxDEV(Slot, { ...props, onClick, ref }, void 0, false, {
|
|
15
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectItemTrigger.tsx",
|
|
16
|
+
lineNumber: 20,
|
|
17
|
+
columnNumber: 9
|
|
18
|
+
}, void 0);
|
|
19
|
+
});
|
|
20
|
+
export {
|
|
21
|
+
SelectItemTrigger
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=SelectItemTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectItemTrigger.js","sources":["../../../../../packages/react-select/src/components/SelectItemTrigger.tsx"],"sourcesContent":["import React, { forwardRef, ReactElement, useCallback } from 'react'\nimport { useSelectHandleSelect } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useEntity } from '@contember/react-binding'\n\nexport type SelectItemTriggerProps = {\n\tchildren: ReactElement\n\taction?: 'select' | 'unselect' | 'toggle'\n\tonClick?: (event: React.MouseEvent<HTMLElement>) => void\n}\n\nexport const SelectItemTrigger = forwardRef<HTMLElement, SelectItemTriggerProps>(({ action, ...props }: SelectItemTriggerProps, ref) => {\n\tconst handleSelect = useSelectHandleSelect()\n\tconst entity = useEntity()\n\tconst onClickProp = props.onClick\n\tconst onClick = useCallback((e: React.MouseEvent<HTMLElement>) => {\n\t\thandleSelect?.(entity, action)\n\t\tonClickProp?.(e)\n\t}, [action, entity, handleSelect, onClickProp])\n\treturn <Slot {...props} onClick={onClick} ref={ref} />\n})\n"],"names":["this"],"mappings":";;;;;AAWO,MAAM,oBAAoB,WAAgD,CAAC,EAAE,QAAQ,GAAG,MAAA,GAAiC,QAAQ;AACvI,QAAM,eAAe,sBAAA;AACrB,QAAM,SAAS,UAAA;AACf,QAAM,cAAc,MAAM;AAC1B,QAAM,UAAU,YAAY,CAAC,MAAqC;AACjE,mBAAe,QAAQ,MAAM;AAC7B,kBAAc,CAAC;AAAA,EAChB,GAAG,CAAC,QAAQ,QAAQ,cAAc,WAAW,CAAC;AAC9C,SAAO,uBAAC,MAAA,EAAM,GAAG,OAAO,SAAkB,IAAA,GAAnC,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAA6C;AACrD,CAAC;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const reactBinding = require("@contember/react-binding");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const contexts = require("../contexts.cjs");
|
|
7
|
+
const SelectNewItem = ({ children }) => {
|
|
8
|
+
const options = contexts.useSelectOptions();
|
|
9
|
+
const env = reactBinding.useEnvironment();
|
|
10
|
+
const { entityName } = React.useMemo(() => reactBinding.QueryLanguage.desugarQualifiedEntityList({ entities: options }, env), [env, options]);
|
|
11
|
+
const [state, setState] = React.useState(null);
|
|
12
|
+
const extendTree = reactBinding.useExtendTree();
|
|
13
|
+
const getSubTree = reactBinding.useGetEntitySubTree();
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
(async () => {
|
|
16
|
+
const treeRootId = await extendTree(
|
|
17
|
+
/* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
18
|
+
reactBinding.EntitySubTree,
|
|
19
|
+
{
|
|
20
|
+
entity: {
|
|
21
|
+
entityName
|
|
22
|
+
},
|
|
23
|
+
expectedMutation: "none",
|
|
24
|
+
isUnpersisted: true,
|
|
25
|
+
isCreating: true,
|
|
26
|
+
children
|
|
27
|
+
},
|
|
28
|
+
void 0,
|
|
29
|
+
false,
|
|
30
|
+
{
|
|
31
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
32
|
+
lineNumber: 29,
|
|
33
|
+
columnNumber: 6
|
|
34
|
+
},
|
|
35
|
+
void 0
|
|
36
|
+
) }, void 0, false, {
|
|
37
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
38
|
+
lineNumber: 28,
|
|
39
|
+
columnNumber: 5
|
|
40
|
+
}, void 0)
|
|
41
|
+
);
|
|
42
|
+
if (!treeRootId) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const entity = getSubTree({
|
|
46
|
+
entity: {
|
|
47
|
+
entityName
|
|
48
|
+
},
|
|
49
|
+
isCreating: true
|
|
50
|
+
}, treeRootId);
|
|
51
|
+
setState({
|
|
52
|
+
entity,
|
|
53
|
+
treeRootId
|
|
54
|
+
});
|
|
55
|
+
})();
|
|
56
|
+
}, [children, entityName, extendTree, getSubTree]);
|
|
57
|
+
if (!state) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.TreeRootIdProvider, { treeRootId: state.treeRootId, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Entity, { accessor: state.entity, children }, void 0, false, {
|
|
61
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
62
|
+
lineNumber: 65,
|
|
63
|
+
columnNumber: 5
|
|
64
|
+
}, void 0) }, void 0, false, {
|
|
65
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
66
|
+
lineNumber: 64,
|
|
67
|
+
columnNumber: 4
|
|
68
|
+
}, void 0) }, void 0, false, {
|
|
69
|
+
fileName: "/home/runner/work/contember/contember/packages/react-select/src/components/SelectNewItem.tsx",
|
|
70
|
+
lineNumber: 63,
|
|
71
|
+
columnNumber: 3
|
|
72
|
+
}, void 0);
|
|
73
|
+
};
|
|
74
|
+
exports.SelectNewItem = SelectNewItem;
|
|
75
|
+
//# sourceMappingURL=SelectNewItem.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectNewItem.cjs","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":["useSelectOptions","useEnvironment","useMemo","QueryLanguage","useState","useExtendTree","useGetEntitySubTree","useEffect","jsxDEV","Fragment","EntitySubTree","this","TreeRootIdProvider","Entity"],"mappings":";;;;;;AAeO,MAAM,gBAAgB,CAAC,EAAE,eAAwC;AACvE,QAAM,UAAUA,SAAAA,iBAAA;AAChB,QAAM,MAAMC,aAAAA,eAAA;AACZ,QAAM,EAAE,WAAA,IAAeC,MAAAA,QAAQ,MAAMC,aAAAA,cAAc,2BAA2B,EAAE,UAAU,QAAA,GAAW,GAAG,GAAG,CAAC,KAAK,OAAO,CAAC;AAEzH,QAAM,CAAC,OAAO,QAAQ,IAAIC,MAAAA,SAAoE,IAAI;AAClG,QAAM,aAAaC,aAAAA,cAAA;AACnB,QAAM,aAAaC,aAAAA,oBAAA;AAEnBC,QAAAA,UAAU,MAAM;AACd,KAAC,YAAY;AACb,YAAM,aAAa,MAAM;AAAA,QACxBC,qCAAAC,cAAAA,UAAA,EACC,UAAAD,8BAAAA;AAAAA,UAACE,aAAAA;AAAAA,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,UAAAC;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,SACCH,8BAAAA,OAAAC,cAAAA,UAAA,EACC,UAAAD,8BAAAA,OAACI,iCAAA,EAAmB,YAAY,MAAM,YACrC,UAAAJ,qCAACK,aAAAA,QAAA,EAAO,UAAU,MAAM,QACtB,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAF,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;;"}
|