@contember/react-select 2.1.0-alpha.9 → 2.1.0-beta.1

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.
Files changed (71) hide show
  1. package/CLAUDE.md +20 -0
  2. package/dist/development/index.cjs +2 -2
  3. package/dist/development/index.js +1 -1
  4. package/dist/development/src/components/MultiSelect.cjs.map +1 -1
  5. package/dist/development/src/components/MultiSelect.js.map +1 -1
  6. package/dist/development/src/components/Select.cjs.map +1 -1
  7. package/dist/development/src/components/Select.js.map +1 -1
  8. package/dist/development/src/components/SelectDataView.cjs.map +1 -1
  9. package/dist/development/src/components/SelectDataView.js.map +1 -1
  10. package/dist/development/src/components/SelectEachItem.cjs +1 -1
  11. package/dist/development/src/components/SelectEachItem.cjs.map +1 -1
  12. package/dist/development/src/components/SelectEachItem.js +1 -1
  13. package/dist/development/src/components/SelectEachItem.js.map +1 -1
  14. package/dist/development/src/components/SelectItemTrigger.cjs.map +1 -1
  15. package/dist/development/src/components/SelectItemTrigger.js.map +1 -1
  16. package/dist/development/src/components/SelectNewItem.cjs +29 -14
  17. package/dist/development/src/components/SelectNewItem.cjs.map +1 -1
  18. package/dist/development/src/components/SelectNewItem.js +29 -14
  19. package/dist/development/src/components/SelectNewItem.js.map +1 -1
  20. package/dist/development/src/components/SelectOption.cjs.map +1 -1
  21. package/dist/development/src/components/SelectOption.js.map +1 -1
  22. package/dist/development/src/components/SelectPlaceholder.cjs.map +1 -1
  23. package/dist/development/src/components/SelectPlaceholder.js.map +1 -1
  24. package/dist/development/src/components/SortableMultiSelect.cjs +70 -67
  25. package/dist/development/src/components/SortableMultiSelect.cjs.map +1 -1
  26. package/dist/development/src/components/SortableMultiSelect.js +70 -67
  27. package/dist/development/src/components/SortableMultiSelect.js.map +1 -1
  28. package/dist/development/src/contexts.cjs.map +1 -1
  29. package/dist/development/src/contexts.js.map +1 -1
  30. package/dist/production/index.cjs +2 -2
  31. package/dist/production/index.js +1 -1
  32. package/dist/production/src/components/MultiSelect.cjs.map +1 -1
  33. package/dist/production/src/components/MultiSelect.js.map +1 -1
  34. package/dist/production/src/components/Select.cjs.map +1 -1
  35. package/dist/production/src/components/Select.js.map +1 -1
  36. package/dist/production/src/components/SelectDataView.cjs.map +1 -1
  37. package/dist/production/src/components/SelectDataView.js.map +1 -1
  38. package/dist/production/src/components/SelectEachItem.cjs.map +1 -1
  39. package/dist/production/src/components/SelectEachItem.js.map +1 -1
  40. package/dist/production/src/components/SelectItemTrigger.cjs.map +1 -1
  41. package/dist/production/src/components/SelectItemTrigger.js.map +1 -1
  42. package/dist/production/src/components/SelectNewItem.cjs +14 -3
  43. package/dist/production/src/components/SelectNewItem.cjs.map +1 -1
  44. package/dist/production/src/components/SelectNewItem.js +14 -3
  45. package/dist/production/src/components/SelectNewItem.js.map +1 -1
  46. package/dist/production/src/components/SelectOption.cjs.map +1 -1
  47. package/dist/production/src/components/SelectOption.js.map +1 -1
  48. package/dist/production/src/components/SelectPlaceholder.cjs.map +1 -1
  49. package/dist/production/src/components/SelectPlaceholder.js.map +1 -1
  50. package/dist/production/src/components/SortableMultiSelect.cjs +42 -39
  51. package/dist/production/src/components/SortableMultiSelect.cjs.map +1 -1
  52. package/dist/production/src/components/SortableMultiSelect.js +42 -39
  53. package/dist/production/src/components/SortableMultiSelect.js.map +1 -1
  54. package/dist/production/src/contexts.cjs.map +1 -1
  55. package/dist/production/src/contexts.js.map +1 -1
  56. package/dist/types/components/SelectDataView.d.ts.map +1 -1
  57. package/dist/types/components/SelectEachItem.d.ts.map +1 -1
  58. package/dist/types/components/SelectNewItem.d.ts.map +1 -1
  59. package/dist/types/components/SortableMultiSelect.d.ts.map +1 -1
  60. package/dist/types/contexts.d.ts +6 -6
  61. package/dist/types/contexts.d.ts.map +1 -1
  62. package/dist/types/tsconfig.tsbuildinfo +1 -1
  63. package/package.json +12 -12
  64. package/src/components/MultiSelect.tsx +1 -2
  65. package/src/components/Select.tsx +0 -1
  66. package/src/components/SelectDataView.tsx +1 -1
  67. package/src/components/SelectEachItem.tsx +0 -1
  68. package/src/components/SelectItemTrigger.tsx +1 -1
  69. package/src/components/SelectNewItem.tsx +27 -10
  70. package/src/components/SortableMultiSelect.tsx +64 -60
  71. package/src/contexts.ts +0 -2
@@ -1 +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","jsx","Slot"],"mappings":";;;;;;;AAWa,MAAA,oBAAoBA,iBAAgD,CAAC,EAAE,QAAQ,GAAG,SAAiC,QAAQ;AACvI,QAAM,eAAeC,SAAAA,sBAAsB;AAC3C,QAAM,SAASC,aAAAA,UAAU;AACzB,QAAM,cAAc,MAAM;AACpB,QAAA,UAAUC,kBAAY,CAAC,MAAqC;AACjE,mBAAe,QAAQ,MAAM;AAC7B,kBAAc,CAAC;AAAA,KACb,CAAC,QAAQ,QAAQ,cAAc,WAAW,CAAC;AAC9C,SAAQC,2BAAAA,IAAAC,UAAAA,MAAA,EAAM,GAAG,OAAO,SAAmB,KAAU;AACtD,CAAC;;"}
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","jsx","Slot"],"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,2BAAAA,IAACC,UAAAA,MAAA,EAAM,GAAG,OAAO,SAAkB,KAAU;AACrD,CAAC;;"}
@@ -1 +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":[],"mappings":";;;;;AAWa,MAAA,oBAAoB,WAAgD,CAAC,EAAE,QAAQ,GAAG,SAAiC,QAAQ;AACvI,QAAM,eAAe,sBAAsB;AAC3C,QAAM,SAAS,UAAU;AACzB,QAAM,cAAc,MAAM;AACpB,QAAA,UAAU,YAAY,CAAC,MAAqC;AACjE,mBAAe,QAAQ,MAAM;AAC7B,kBAAc,CAAC;AAAA,KACb,CAAC,QAAQ,QAAQ,cAAc,WAAW,CAAC;AAC9C,SAAQ,oBAAA,MAAA,EAAM,GAAG,OAAO,SAAmB,KAAU;AACtD,CAAC;"}
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":[],"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,oBAAC,MAAA,EAAM,GAAG,OAAO,SAAkB,KAAU;AACrD,CAAC;"}
@@ -13,9 +13,20 @@ const SelectNewItem = ({ children }) => {
13
13
  const getSubTree = reactBinding.useGetEntitySubTree();
14
14
  React.useEffect(() => {
15
15
  (async () => {
16
- const treeRootId = await extendTree(/* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(reactBinding.EntitySubTree, { entity: {
17
- entityName
18
- }, expectedMutation: "none", isUnpersisted: true, isCreating: true, children }) }));
16
+ const treeRootId = await extendTree(
17
+ /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
18
+ reactBinding.EntitySubTree,
19
+ {
20
+ entity: {
21
+ entityName
22
+ },
23
+ expectedMutation: "none",
24
+ isUnpersisted: true,
25
+ isCreating: true,
26
+ children
27
+ }
28
+ ) })
29
+ );
19
30
  if (!treeRootId) {
20
31
  return;
21
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectNewItem.cjs","sources":["../../../../../packages/react-select/src/components/SelectNewItem.tsx"],"sourcesContent":["import { Entity, EntityAccessor, EntitySubTree, QueryLanguage, TreeRootId, TreeRootIdProvider, useEnvironment, useExtendTree, useGetEntitySubTree } 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<EntitySubTree entity={{\n\t\t\t\t\tentityName,\n\t\t\t\t}} expectedMutation={'none'} isUnpersisted isCreating>\n\t\t\t\t\t{children}\n\t\t\t\t</EntitySubTree>\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","jsx","Fragment","EntitySubTree","TreeRootIdProvider","Entity"],"mappings":";;;;;;AAKO,MAAM,gBAAgB,CAAC,EAAE,eAAwC;AACvE,QAAM,UAAUA,SAAAA,iBAAiB;AACjC,QAAM,MAAMC,aAAAA,eAAe;AAC3B,QAAM,EAAE,WAAW,IAAIC,MAAS,QAAA,MAAMC,aAAAA,cAAc,2BAA2B,EAAE,UAAU,WAAW,GAAG,GAAI,CAAC,KAAK,OAAO,CAAC;AAE3H,QAAM,CAAC,OAAO,QAAQ,IAAIC,MAAAA,SAAoE,IAAI;AAClG,QAAM,aAAaC,aAAAA,cAAc;AACjC,QAAM,aAAaC,aAAAA,oBAAoB;AAEvCC,QAAAA,UAAU,MAAM;AACf,KAAC,YAAY;AACZ,YAAM,aAAa,MAAM,WACxBC,+BAAAC,WAAAA,UAAA,EAAA,UAAAD,2BAAA,IAACE,8BAAc,QAAQ;AAAA,QACtB;AAAA,MAAA,GACE,kBAAkB,QAAQ,eAAa,MAAC,YAAU,MACnD,UACF,EAAA,CACD,CAAG;AACH,UAAI,CAAC,YAAY;AAChB;AAAA,MAAA;AAGD,YAAM,SAAS,WAAW;AAAA,QACzB,QAAQ;AAAA,UACP;AAAA,QACD;AAAA,QACA,YAAY;AAAA,SACV,UAAU;AACJ,eAAA;AAAA,QACR;AAAA,QACA;AAAA,MAAA,CACA;AAAA,IAAA,GACC;AAAA,KACD,CAAC,UAAU,YAAY,YAAY,UAAU,CAAC;AAEjD,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,EAAA;AAGR,SAEEF,2BAAA,IAAAC,WAAA,UAAA,EAAA,UAAAD,2BAAA,IAACG,iCAAmB,EAAA,YAAY,MAAM,YACrC,UAACH,+BAAAI,aAAAA,QAAA,EAAO,UAAU,MAAM,QACtB,SAAA,CACF,EACD,CAAA,GACD;AAEF;;"}
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","jsx","Fragment","EntitySubTree","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,+BAAAC,WAAAA,UAAA,EACC,UAAAD,2BAAAA;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,QAAA,EACF,CACD;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,SACCF,2BAAAA,IAAAC,WAAAA,UAAA,EACC,UAAAD,2BAAAA,IAACG,iCAAA,EAAmB,YAAY,MAAM,YACrC,UAAAH,+BAACI,aAAAA,QAAA,EAAO,UAAU,MAAM,QACtB,SAAA,CACF,GACD,GACD;AAEF;;"}
@@ -11,9 +11,20 @@ const SelectNewItem = ({ children }) => {
11
11
  const getSubTree = useGetEntitySubTree();
12
12
  useEffect(() => {
13
13
  (async () => {
14
- const treeRootId = await extendTree(/* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(EntitySubTree, { entity: {
15
- entityName
16
- }, expectedMutation: "none", isUnpersisted: true, isCreating: true, children }) }));
14
+ const treeRootId = await extendTree(
15
+ /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
16
+ EntitySubTree,
17
+ {
18
+ entity: {
19
+ entityName
20
+ },
21
+ expectedMutation: "none",
22
+ isUnpersisted: true,
23
+ isCreating: true,
24
+ children
25
+ }
26
+ ) })
27
+ );
17
28
  if (!treeRootId) {
18
29
  return;
19
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectNewItem.js","sources":["../../../../../packages/react-select/src/components/SelectNewItem.tsx"],"sourcesContent":["import { Entity, EntityAccessor, EntitySubTree, QueryLanguage, TreeRootId, TreeRootIdProvider, useEnvironment, useExtendTree, useGetEntitySubTree } 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<EntitySubTree entity={{\n\t\t\t\t\tentityName,\n\t\t\t\t}} expectedMutation={'none'} isUnpersisted isCreating>\n\t\t\t\t\t{children}\n\t\t\t\t</EntitySubTree>\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":[],"mappings":";;;;AAKO,MAAM,gBAAgB,CAAC,EAAE,eAAwC;AACvE,QAAM,UAAU,iBAAiB;AACjC,QAAM,MAAM,eAAe;AAC3B,QAAM,EAAE,WAAW,IAAI,QAAS,MAAM,cAAc,2BAA2B,EAAE,UAAU,WAAW,GAAG,GAAI,CAAC,KAAK,OAAO,CAAC;AAE3H,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoE,IAAI;AAClG,QAAM,aAAa,cAAc;AACjC,QAAM,aAAa,oBAAoB;AAEvC,YAAU,MAAM;AACf,KAAC,YAAY;AACZ,YAAM,aAAa,MAAM,WACxB,oBAAA,UAAA,EAAA,UAAA,oBAAC,iBAAc,QAAQ;AAAA,QACtB;AAAA,MAAA,GACE,kBAAkB,QAAQ,eAAa,MAAC,YAAU,MACnD,UACF,EAAA,CACD,CAAG;AACH,UAAI,CAAC,YAAY;AAChB;AAAA,MAAA;AAGD,YAAM,SAAS,WAAW;AAAA,QACzB,QAAQ;AAAA,UACP;AAAA,QACD;AAAA,QACA,YAAY;AAAA,SACV,UAAU;AACJ,eAAA;AAAA,QACR;AAAA,QACA;AAAA,MAAA,CACA;AAAA,IAAA,GACC;AAAA,KACD,CAAC,UAAU,YAAY,YAAY,UAAU,CAAC;AAEjD,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,EAAA;AAGR,SAEE,oBAAA,UAAA,EAAA,UAAA,oBAAC,oBAAmB,EAAA,YAAY,MAAM,YACrC,UAAC,oBAAA,QAAA,EAAO,UAAU,MAAM,QACtB,SAAA,CACF,EACD,CAAA,GACD;AAEF;"}
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":[],"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,oBAAA,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,QAAA,EACF,CACD;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,oBAAA,UAAA,EACC,UAAA,oBAAC,oBAAA,EAAmB,YAAY,MAAM,YACrC,UAAA,oBAAC,QAAA,EAAO,UAAU,MAAM,QACtB,SAAA,CACF,GACD,GACD;AAEF;"}
@@ -1 +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","jsx","Slot","dataAttribute"],"mappings":";;;;;;;;AAWa,MAAA,eAAeA,iBAA2C,CAAC,EAAE,QAAQ,GAAG,SAAS,QAAQ;AACrG,QAAM,aAAaC,SAAAA,oBAAoB;AACvC,QAAM,SAASC,aAAAA,UAAU;AAExB,SAAAC,2BAAA;AAAA,IAACC,UAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,iBAAeC,UAAA,cAAc,aAAa,MAAM,CAAC;AAAA,MAChD,GAAG;AAAA,IAAA;AAAA,EACL;AAEF,CAAC;;"}
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","jsx","Slot","dataAttribute"],"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,2BAAAA;AAAAA,IAACC,UAAAA;AAAAA,IAAA;AAAA,MACA;AAAA,MACA,iBAAeC,UAAAA,cAAc,aAAa,MAAM,CAAC;AAAA,MAChD,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;;"}
@@ -1 +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":[],"mappings":";;;;;;AAWa,MAAA,eAAe,WAA2C,CAAC,EAAE,QAAQ,GAAG,SAAS,QAAQ;AACrG,QAAM,aAAa,oBAAoB;AACvC,QAAM,SAAS,UAAU;AAExB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,iBAAe,cAAc,aAAa,MAAM,CAAC;AAAA,MAChD,GAAG;AAAA,IAAA;AAAA,EACL;AAEF,CAAC;"}
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":[],"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,EAAA;AAGP,CAAC;"}
@@ -1 +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","jsx","Fragment"],"mappings":";;;;AAGO,MAAM,oBAAoB,CAAC,EAAE,eAAwC;AACrE,QAAA,cAAcA,SAAAA,2BAA2B,SAAS;AACjD,SAAA,cAAc,OAAOC,2BAAAA,IAAAC,WAAAA,UAAA,EAAG,SAAS,CAAA;AACzC;;"}
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","jsx","Fragment"],"mappings":";;;;AAGO,MAAM,oBAAoB,CAAC,EAAE,eAAwC;AAC3E,QAAM,cAAcA,SAAAA,2BAA2B,SAAS;AACxD,SAAO,cAAc,OAAOC,2BAAAA,IAAAC,WAAAA,UAAA,EAAG,SAAA,CAAS;AACzC;;"}
@@ -1 +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":[],"mappings":";;AAGO,MAAM,oBAAoB,CAAC,EAAE,eAAwC;AACrE,QAAA,cAAc,2BAA2B,SAAS;AACjD,SAAA,cAAc,OAAO,oBAAA,UAAA,EAAG,SAAS,CAAA;AACzC;"}
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":[],"mappings":";;AAGO,MAAM,oBAAoB,CAAC,EAAE,eAAwC;AAC3E,QAAM,cAAc,2BAA2B,SAAS;AACxD,SAAO,cAAc,OAAO,oBAAA,UAAA,EAAG,SAAA,CAAS;AACzC;"}
@@ -6,45 +6,48 @@ const contexts = require("../contexts.cjs");
6
6
  const reactBinding = require("@contember/react-binding");
7
7
  const reactUtils = require("@contember/react-utils");
8
8
  const reactRepeater = require("@contember/react-repeater");
9
- const SortableMultiSelect = reactBinding.Component(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }) => {
10
- const list = reactBinding.useEntityList({ field });
11
- const entitiesArr = React.useMemo(() => Array.from(list), [list]);
12
- const optionsMarker = React.useMemo(() => {
13
- const desugared = reactBinding.QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment);
14
- let marker = list.getMarker();
15
- for (let relation of desugared.hasOneRelationPath) {
16
- const placeholder = reactBinding.PlaceholderGenerator.getHasOneRelationPlaceholder(relation);
17
- const relationMarker = marker.fields.markers.get(placeholder);
18
- if (!relationMarker || relationMarker instanceof reactBinding.FieldMarker) {
19
- throw new Error("Invalid marker");
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;
20
23
  }
21
- marker = relationMarker;
22
- }
23
- return marker;
24
- }, [connectAt, list]);
25
- options ?? (options = optionsMarker.environment.getSubTreeNode().entity.name);
26
- const selectedEntities = React.useMemo(() => Array.from(list).map((it) => it.getEntity({ field: connectAt }).id), [connectAt, list]);
27
- const handler = reactUtils.useReferentiallyStableCallback((entity, action = "toggle") => {
28
- const isSelected2 = selectedEntities.includes(entity.id);
29
- if (action === "toggle") {
30
- action = isSelected2 ? "unselect" : "select";
31
- }
32
- if (action === "unselect" && isSelected2) {
33
- Array.from(list).find((it) => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity();
34
- onUnselect?.(entity);
35
- } else if (action === "select" && !isSelected2) {
36
- list.createNewEntity((getEntity) => {
37
- getEntity().connectEntityAtField({ field: connectAt }, entity);
38
- onSelect?.(entity);
39
- });
40
- }
41
- });
42
- const isSelected = React.useCallback((entity) => {
43
- return selectedEntities.includes(entity.id);
44
- }, [selectedEntities]);
45
- return /* @__PURE__ */ jsxRuntime.jsx(reactRepeater.Repeater, { field, sortableBy, initialEntityCount: 0, orderBy: false, children: /* @__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 }) }) }) }) });
46
- }, ({ children, field, sortableBy, connectAt }) => {
47
- return /* @__PURE__ */ jsxRuntime.jsx(reactRepeater.Repeater, { field, sortableBy, initialEntityCount: 0, orderBy: false, children: /* @__PURE__ */ jsxRuntime.jsx(reactBinding.HasOne, { field: connectAt, expectedMutation: "connectOrDisconnect", children }) });
48
- });
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__ */ jsxRuntime.jsx(reactRepeater.Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__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 }) }) }) }) });
47
+ },
48
+ ({ children, field, sortableBy, connectAt }) => {
49
+ return /* @__PURE__ */ jsxRuntime.jsx(reactRepeater.Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsxRuntime.jsx(reactBinding.HasOne, { field: connectAt, expectedMutation: "connectOrDisconnect", children }) });
50
+ }
51
+ );
49
52
  exports.SortableMultiSelect = SortableMultiSelect;
50
53
  //# sourceMappingURL=SortableMultiSelect.cjs.map
@@ -1 +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\tFieldMarker,\n\tHasOne,\n\tMeaningfulMarker,\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(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\tconst list = useEntityList({ field })\n\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\tconst optionsMarker = useMemo(() => {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment)\n\t\tlet marker: Exclude<MeaningfulMarker, FieldMarker> = list.getMarker()\n\t\tfor (let relation of desugared.hasOneRelationPath) {\n\t\t\tconst placeholder = PlaceholderGenerator.getHasOneRelationPlaceholder(relation)\n\t\t\tconst relationMarker = marker.fields.markers.get(placeholder)\n\t\t\tif (!relationMarker || relationMarker instanceof FieldMarker) {\n\t\t\t\tthrow new Error('Invalid marker')\n\t\t\t}\n\t\t\tmarker = relationMarker\n\t\t}\n\t\treturn marker\n\t}, [connectAt, list])\n\n\toptions ??= optionsMarker.environment.getSubTreeNode().entity.name\n\n\n\tconst selectedEntities = useMemo(() => Array.from(list).map(it => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\tif (action === 'toggle') {\n\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect' && isSelected) {\n\t\t\tArray.from(list).find(it => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\tonUnselect?.(entity)\n\t\t} else if (action === 'select' && !isSelected) {\n\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\tonSelect?.(entity)\n\t\t\t})\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\treturn selectedEntities.includes(entity.id)\n\t}, [selectedEntities])\n\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0} orderBy={false}>\n\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t</Repeater>\n\t)\n}, ({ children, field, sortableBy, connectAt }) => {\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0} orderBy={false}>\n\t\t\t<HasOne field={connectAt} expectedMutation=\"connectOrDisconnect\">\n\t\t\t\t{children}\n\t\t\t</HasOne>\n\t\t</Repeater>\n\t)\n})\n\n"],"names":["Component","useEntityList","useMemo","QueryLanguage","PlaceholderGenerator","FieldMarker","useReferentiallyStableCallback","isSelected","useCallback","Repeater","jsx","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","HasOne"],"mappings":";;;;;;;;AA8Ba,MAAA,sBAAsBA,aAAU,UAAA,CAAC,EAAE,OAAO,UAAU,YAAY,WAAW,SAAS,UAAU,iBAA2C;AACrJ,QAAM,OAAOC,aAAAA,cAAc,EAAE,OAAO;AAC9B,QAAA,cAAcC,cAAQ,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;AAEpD,QAAA,gBAAgBA,MAAAA,QAAQ,MAAM;AAC7B,UAAA,YAAYC,2BAAc,4BAA4B,EAAE,OAAO,UAAU,GAAG,KAAK,WAAW;AAC9F,QAAA,SAAiD,KAAK,UAAU;AAC3D,aAAA,YAAY,UAAU,oBAAoB;AAC5C,YAAA,cAAcC,aAAAA,qBAAqB,6BAA6B,QAAQ;AAC9E,YAAM,iBAAiB,OAAO,OAAO,QAAQ,IAAI,WAAW;AACxD,UAAA,CAAC,kBAAkB,0BAA0BC,0BAAa;AACvD,cAAA,IAAI,MAAM,gBAAgB;AAAA,MAAA;AAExB,eAAA;AAAA,IAAA;AAEH,WAAA;AAAA,EAAA,GACL,CAAC,WAAW,IAAI,CAAC;AAEpB,cAAA,UAAY,cAAc,YAAY,eAAe,EAAE,OAAO;AAGxD,QAAA,mBAAmBH,cAAQ,MAAM,MAAM,KAAK,IAAI,EAAE,IAAI,CAAM,OAAA,GAAG,UAAU,EAAE,OAAO,UAAW,CAAA,EAAE,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;AAE3H,QAAM,UAAUI,WAAA,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,UAAMC,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,QAAI,WAAW,UAAU;AACxB,eAASA,cAAa,aAAa;AAAA,IAAA;AAEhC,QAAA,WAAW,cAAcA,aAAY;AACxC,YAAM,KAAK,IAAI,EAAE,KAAK,CAAA,OAAM,GAAG,UAAU,EAAE,OAAO,UAAA,CAAW,EAAE,OAAO,OAAO,EAAE,GAAG,aAAa;AAC/F,mBAAa,MAAM;AAAA,IACT,WAAA,WAAW,YAAY,CAACA,aAAY;AAC9C,WAAK,gBAAgB,CAAa,cAAA;AACjC,kBAAA,EAAY,qBAAqB,EAAE,OAAO,UAAA,GAAa,MAAM;AAC7D,mBAAW,MAAM;AAAA,MAAA,CACjB;AAAA,IAAA;AAAA,EACF,CACA;AACK,QAAA,aAAaC,kBAAY,CAAC,WAA2B;AACnD,WAAA,iBAAiB,SAAS,OAAO,EAAE;AAAA,EAAA,GACxC,CAAC,gBAAgB,CAAC;AAErB,wCACEC,cAAS,UAAA,EAAA,OAAc,YAAwB,oBAAoB,GAAG,SAAS,OAC/E,UAACC,2BAAAA,IAAAC,SAAA,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAAD,2BAAAA,IAACE,iCAAwB,UAAxB,EAAiC,OAAO,YACxC,yCAACC,SAA0B,0BAAA,UAA1B,EAAmC,OAAO,SAC1C,UAACH,2BAAA,IAAAI,SAAA,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SACF,CAAA,GACD,EAAA,CACD,EACD,CAAA,GACD;AAEF,GAAG,CAAC,EAAE,UAAU,OAAO,YAAY,gBAAgB;AAClD,SACEJ,2BAAA,IAAAD,cAAA,UAAA,EAAS,OAAc,YAAwB,oBAAoB,GAAG,SAAS,OAC/E,UAAAC,+BAACK,aAAAA,UAAO,OAAO,WAAW,kBAAiB,uBACzC,SACF,CAAA,GACD;AAEF,CAAC;;"}
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","jsx","Repeater","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","HasOne"],"mappings":";;;;;;;;AAiCO,MAAM,sBAAsBA,aAAAA;AAAAA,EAClC,CAAC,EAAE,OAAO,UAAU,YAAY,WAAW,SAAS,UAAU,iBAA2C;AACxG,UAAM,OAAOC,aAAAA,cAAc,EAAE,OAAO;AACpC,UAAM,cAAcC,MAAAA,QAAQ,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;AAE1D,UAAM,gBAAgBA,MAAAA,QAAQ,MAAM;AACnC,YAAM,YAAYC,aAAAA,cAAc,4BAA4B,EAAE,OAAO,UAAA,GAAa,KAAK,WAAW;AAClG,UAAI,SAAuG,KAAK,UAAA;AAChH,eAAS,YAAY,UAAU,oBAAoB;AAClD,cAAM,cAAcC,aAAAA,qBAAqB,6BAA6B,QAAQ;AAC9E,cAAM,iBAAiB,OAAO,OAAO,QAAQ,IAAI,WAAW;AAC5D,YAAI,CAAC,kBAAkB,0BAA0BC,0BAAa;AAC7D,gBAAM,IAAI,MAAM,gBAAgB;AAAA,QACjC;AACA,iBAAS;AAAA,MACV;AACA,aAAO;AAAA,IACR,GAAG,CAAC,WAAW,IAAI,CAAC;AAEpB,gBAAA,UAAY,cAAc,YAAY,eAAA,EAAiB,OAAO;AAE9D,UAAM,mBAAmBH,MAAAA,QAAQ,MAAM,MAAM,KAAK,IAAI,EAAE,IAAI,CAAC,OAAuB,GAAG,UAAU,EAAE,OAAO,WAAW,EAAE,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;AAE7I,UAAM,UAAUI,WAAAA,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,YAAMC,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,UAAI,WAAW,UAAU;AACxB,iBAASA,cAAa,aAAa;AAAA,MACpC;AACA,UAAI,WAAW,cAAcA,aAAY;AACxC,cAAM,KAAK,IAAI,EAAE,KAAK,CAAC,OAAuB,GAAG,UAAU,EAAE,OAAO,WAAW,EAAE,OAAO,OAAO,EAAE,GAAG,aAAA;AACpG,qBAAa,MAAM;AAAA,MACpB,WAAW,WAAW,YAAY,CAACA,aAAY;AAC9C,aAAK,gBAAgB,CAAA,cAAa;AACjC,oBAAA,EAAY,qBAAqB,EAAE,OAAO,UAAA,GAAa,MAAM;AAC7D,qBAAW,MAAM;AAAA,QAClB,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AACD,UAAM,aAAaC,kBAAY,CAAC,WAA2B;AAC1D,aAAO,iBAAiB,SAAS,OAAO,EAAE;AAAA,IAC3C,GAAG,CAAC,gBAAgB,CAAC;AAErB,WACCC,2BAAAA,IAACC,cAAAA,UAAA,EAAS,OAAc,YAAwB,oBAAoB,GACnE,UAAAD,2BAAAA,IAACE,SAAAA,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAAF,2BAAAA,IAACG,SAAAA,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,UAAAH,2BAAAA,IAACI,SAAAA,0BAA0B,UAA1B,EAAmC,OAAO,SAC1C,UAAAJ,+BAACK,SAAAA,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SAAA,CACF,EAAA,CACD,EAAA,CACD,GACD,GACD;AAAA,EAEF;AAAA,EACA,CAAC,EAAE,UAAU,OAAO,YAAY,gBAAgB;AAC/C,WACCL,2BAAAA,IAACC,cAAAA,UAAA,EAAS,OAAc,YAAwB,oBAAoB,GACnE,UAAAD,2BAAAA,IAACM,aAAAA,QAAA,EAAO,OAAO,WAAW,kBAAiB,uBACzC,UACF,GACD;AAAA,EAEF;AACD;;"}
@@ -4,46 +4,49 @@ import { SelectCurrentEntitiesContext, SelectIsSelectedContext, SelectHandleSele
4
4
  import { Component, useEntityList, QueryLanguage, PlaceholderGenerator, FieldMarker, HasOne } from "@contember/react-binding";
5
5
  import { useReferentiallyStableCallback } from "@contember/react-utils";
6
6
  import { Repeater } from "@contember/react-repeater";
7
- const SortableMultiSelect = Component(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }) => {
8
- const list = useEntityList({ field });
9
- const entitiesArr = useMemo(() => Array.from(list), [list]);
10
- const optionsMarker = useMemo(() => {
11
- const desugared = QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment);
12
- let marker = list.getMarker();
13
- for (let relation of desugared.hasOneRelationPath) {
14
- const placeholder = PlaceholderGenerator.getHasOneRelationPlaceholder(relation);
15
- const relationMarker = marker.fields.markers.get(placeholder);
16
- if (!relationMarker || relationMarker instanceof FieldMarker) {
17
- throw new Error("Invalid marker");
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;
18
21
  }
19
- marker = relationMarker;
20
- }
21
- return marker;
22
- }, [connectAt, list]);
23
- options ?? (options = optionsMarker.environment.getSubTreeNode().entity.name);
24
- const selectedEntities = useMemo(() => Array.from(list).map((it) => it.getEntity({ field: connectAt }).id), [connectAt, list]);
25
- const handler = useReferentiallyStableCallback((entity, action = "toggle") => {
26
- const isSelected2 = selectedEntities.includes(entity.id);
27
- if (action === "toggle") {
28
- action = isSelected2 ? "unselect" : "select";
29
- }
30
- if (action === "unselect" && isSelected2) {
31
- Array.from(list).find((it) => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity();
32
- onUnselect?.(entity);
33
- } else if (action === "select" && !isSelected2) {
34
- list.createNewEntity((getEntity) => {
35
- getEntity().connectEntityAtField({ field: connectAt }, entity);
36
- onSelect?.(entity);
37
- });
38
- }
39
- });
40
- const isSelected = useCallback((entity) => {
41
- return selectedEntities.includes(entity.id);
42
- }, [selectedEntities]);
43
- return /* @__PURE__ */ jsx(Repeater, { field, sortableBy, initialEntityCount: 0, orderBy: false, children: /* @__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 }) }) }) }) });
44
- }, ({ children, field, sortableBy, connectAt }) => {
45
- return /* @__PURE__ */ jsx(Repeater, { field, sortableBy, initialEntityCount: 0, orderBy: false, children: /* @__PURE__ */ jsx(HasOne, { field: connectAt, expectedMutation: "connectOrDisconnect", children }) });
46
- });
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__ */ jsx(Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__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 }) }) }) }) });
45
+ },
46
+ ({ children, field, sortableBy, connectAt }) => {
47
+ return /* @__PURE__ */ jsx(Repeater, { field, sortableBy, initialEntityCount: 0, children: /* @__PURE__ */ jsx(HasOne, { field: connectAt, expectedMutation: "connectOrDisconnect", children }) });
48
+ }
49
+ );
47
50
  export {
48
51
  SortableMultiSelect
49
52
  };
@@ -1 +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\tFieldMarker,\n\tHasOne,\n\tMeaningfulMarker,\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(({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {\n\tconst list = useEntityList({ field })\n\tconst entitiesArr = useMemo(() => Array.from(list), [list])\n\n\tconst optionsMarker = useMemo(() => {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment)\n\t\tlet marker: Exclude<MeaningfulMarker, FieldMarker> = list.getMarker()\n\t\tfor (let relation of desugared.hasOneRelationPath) {\n\t\t\tconst placeholder = PlaceholderGenerator.getHasOneRelationPlaceholder(relation)\n\t\t\tconst relationMarker = marker.fields.markers.get(placeholder)\n\t\t\tif (!relationMarker || relationMarker instanceof FieldMarker) {\n\t\t\t\tthrow new Error('Invalid marker')\n\t\t\t}\n\t\t\tmarker = relationMarker\n\t\t}\n\t\treturn marker\n\t}, [connectAt, list])\n\n\toptions ??= optionsMarker.environment.getSubTreeNode().entity.name\n\n\n\tconst selectedEntities = useMemo(() => Array.from(list).map(it => it.getEntity({ field: connectAt }).id), [connectAt, list])\n\n\tconst handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {\n\t\tconst isSelected = selectedEntities.includes(entity.id)\n\t\tif (action === 'toggle') {\n\t\t\taction = isSelected ? 'unselect' : 'select'\n\t\t}\n\t\tif (action === 'unselect' && isSelected) {\n\t\t\tArray.from(list).find(it => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()\n\t\t\tonUnselect?.(entity)\n\t\t} else if (action === 'select' && !isSelected) {\n\t\t\tlist.createNewEntity(getEntity => {\n\t\t\t\tgetEntity().connectEntityAtField({ field: connectAt }, entity)\n\t\t\t\tonSelect?.(entity)\n\t\t\t})\n\t\t}\n\t})\n\tconst isSelected = useCallback((entity: EntityAccessor) => {\n\t\treturn selectedEntities.includes(entity.id)\n\t}, [selectedEntities])\n\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0} orderBy={false}>\n\t\t\t<SelectCurrentEntitiesContext.Provider value={entitiesArr}>\n\t\t\t\t<SelectIsSelectedContext.Provider value={isSelected}>\n\t\t\t\t\t<SelectHandleSelectContext.Provider value={handler}>\n\t\t\t\t\t\t<SelectOptionsContext.Provider value={options}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</SelectOptionsContext.Provider>\n\t\t\t\t\t</SelectHandleSelectContext.Provider>\n\t\t\t\t</SelectIsSelectedContext.Provider>\n\t\t\t</SelectCurrentEntitiesContext.Provider>\n\t\t</Repeater>\n\t)\n}, ({ children, field, sortableBy, connectAt }) => {\n\treturn (\n\t\t<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0} orderBy={false}>\n\t\t\t<HasOne field={connectAt} expectedMutation=\"connectOrDisconnect\">\n\t\t\t\t{children}\n\t\t\t</HasOne>\n\t\t</Repeater>\n\t)\n})\n\n"],"names":["isSelected"],"mappings":";;;;;;AA8Ba,MAAA,sBAAsB,UAAU,CAAC,EAAE,OAAO,UAAU,YAAY,WAAW,SAAS,UAAU,iBAA2C;AACrJ,QAAM,OAAO,cAAc,EAAE,OAAO;AAC9B,QAAA,cAAc,QAAQ,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;AAEpD,QAAA,gBAAgB,QAAQ,MAAM;AAC7B,UAAA,YAAY,cAAc,4BAA4B,EAAE,OAAO,UAAU,GAAG,KAAK,WAAW;AAC9F,QAAA,SAAiD,KAAK,UAAU;AAC3D,aAAA,YAAY,UAAU,oBAAoB;AAC5C,YAAA,cAAc,qBAAqB,6BAA6B,QAAQ;AAC9E,YAAM,iBAAiB,OAAO,OAAO,QAAQ,IAAI,WAAW;AACxD,UAAA,CAAC,kBAAkB,0BAA0B,aAAa;AACvD,cAAA,IAAI,MAAM,gBAAgB;AAAA,MAAA;AAExB,eAAA;AAAA,IAAA;AAEH,WAAA;AAAA,EAAA,GACL,CAAC,WAAW,IAAI,CAAC;AAEpB,cAAA,UAAY,cAAc,YAAY,eAAe,EAAE,OAAO;AAGxD,QAAA,mBAAmB,QAAQ,MAAM,MAAM,KAAK,IAAI,EAAE,IAAI,CAAM,OAAA,GAAG,UAAU,EAAE,OAAO,UAAW,CAAA,EAAE,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;AAE3H,QAAM,UAAU,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,UAAMA,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,QAAI,WAAW,UAAU;AACxB,eAASA,cAAa,aAAa;AAAA,IAAA;AAEhC,QAAA,WAAW,cAAcA,aAAY;AACxC,YAAM,KAAK,IAAI,EAAE,KAAK,CAAA,OAAM,GAAG,UAAU,EAAE,OAAO,UAAA,CAAW,EAAE,OAAO,OAAO,EAAE,GAAG,aAAa;AAC/F,mBAAa,MAAM;AAAA,IACT,WAAA,WAAW,YAAY,CAACA,aAAY;AAC9C,WAAK,gBAAgB,CAAa,cAAA;AACjC,kBAAA,EAAY,qBAAqB,EAAE,OAAO,UAAA,GAAa,MAAM;AAC7D,mBAAW,MAAM;AAAA,MAAA,CACjB;AAAA,IAAA;AAAA,EACF,CACA;AACK,QAAA,aAAa,YAAY,CAAC,WAA2B;AACnD,WAAA,iBAAiB,SAAS,OAAO,EAAE;AAAA,EAAA,GACxC,CAAC,gBAAgB,CAAC;AAErB,6BACE,UAAS,EAAA,OAAc,YAAwB,oBAAoB,GAAG,SAAS,OAC/E,UAAC,oBAAA,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAA,oBAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,8BAAC,0BAA0B,UAA1B,EAAmC,OAAO,SAC1C,UAAC,oBAAA,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SACF,CAAA,GACD,EAAA,CACD,EACD,CAAA,GACD;AAEF,GAAG,CAAC,EAAE,UAAU,OAAO,YAAY,gBAAgB;AAClD,SACE,oBAAA,UAAA,EAAS,OAAc,YAAwB,oBAAoB,GAAG,SAAS,OAC/E,UAAA,oBAAC,UAAO,OAAO,WAAW,kBAAiB,uBACzC,SACF,CAAA,GACD;AAEF,CAAC;"}
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"],"mappings":";;;;;;AAiCO,MAAM,sBAAsB;AAAA,EAClC,CAAC,EAAE,OAAO,UAAU,YAAY,WAAW,SAAS,UAAU,iBAA2C;AACxG,UAAM,OAAO,cAAc,EAAE,OAAO;AACpC,UAAM,cAAc,QAAQ,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;AAE1D,UAAM,gBAAgB,QAAQ,MAAM;AACnC,YAAM,YAAY,cAAc,4BAA4B,EAAE,OAAO,UAAA,GAAa,KAAK,WAAW;AAClG,UAAI,SAAuG,KAAK,UAAA;AAChH,eAAS,YAAY,UAAU,oBAAoB;AAClD,cAAM,cAAc,qBAAqB,6BAA6B,QAAQ;AAC9E,cAAM,iBAAiB,OAAO,OAAO,QAAQ,IAAI,WAAW;AAC5D,YAAI,CAAC,kBAAkB,0BAA0B,aAAa;AAC7D,gBAAM,IAAI,MAAM,gBAAgB;AAAA,QACjC;AACA,iBAAS;AAAA,MACV;AACA,aAAO;AAAA,IACR,GAAG,CAAC,WAAW,IAAI,CAAC;AAEpB,gBAAA,UAAY,cAAc,YAAY,eAAA,EAAiB,OAAO;AAE9D,UAAM,mBAAmB,QAAQ,MAAM,MAAM,KAAK,IAAI,EAAE,IAAI,CAAC,OAAuB,GAAG,UAAU,EAAE,OAAO,WAAW,EAAE,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;AAE7I,UAAM,UAAU,+BAA8C,CAAC,QAAQ,SAAS,aAAa;AAC5F,YAAMA,cAAa,iBAAiB,SAAS,OAAO,EAAE;AACtD,UAAI,WAAW,UAAU;AACxB,iBAASA,cAAa,aAAa;AAAA,MACpC;AACA,UAAI,WAAW,cAAcA,aAAY;AACxC,cAAM,KAAK,IAAI,EAAE,KAAK,CAAC,OAAuB,GAAG,UAAU,EAAE,OAAO,WAAW,EAAE,OAAO,OAAO,EAAE,GAAG,aAAA;AACpG,qBAAa,MAAM;AAAA,MACpB,WAAW,WAAW,YAAY,CAACA,aAAY;AAC9C,aAAK,gBAAgB,CAAA,cAAa;AACjC,oBAAA,EAAY,qBAAqB,EAAE,OAAO,UAAA,GAAa,MAAM;AAC7D,qBAAW,MAAM;AAAA,QAClB,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AACD,UAAM,aAAa,YAAY,CAAC,WAA2B;AAC1D,aAAO,iBAAiB,SAAS,OAAO,EAAE;AAAA,IAC3C,GAAG,CAAC,gBAAgB,CAAC;AAErB,WACC,oBAAC,UAAA,EAAS,OAAc,YAAwB,oBAAoB,GACnE,UAAA,oBAAC,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAA,oBAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,UAAA,oBAAC,0BAA0B,UAA1B,EAAmC,OAAO,SAC1C,UAAA,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SAAA,CACF,EAAA,CACD,EAAA,CACD,GACD,GACD;AAAA,EAEF;AAAA,EACA,CAAC,EAAE,UAAU,OAAO,YAAY,gBAAgB;AAC/C,WACC,oBAAC,UAAA,EAAS,OAAc,YAAwB,oBAAoB,GACnE,UAAA,oBAAC,QAAA,EAAO,OAAO,WAAW,kBAAiB,uBACzC,UACF,GACD;AAAA,EAEF;AACD;"}
@@ -1 +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\n\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,iCAAwC,8BAA8B;AAE/F,MAAA,+BAA+B,8BAA8B,CAAC;AAC9D,MAAA,2BAA2B,8BAA8B,CAAC;AAIvE,MAAM,2BAA2BA,iCAA2D,yBAAyB;AAExG,MAAA,0BAA0B,yBAAyB,CAAC;AACpD,MAAA,sBAAsB,yBAAyB,CAAC;AAG7D,MAAM,6BAA6BA,iCAAqC,2BAA2B;AAEtF,MAAA,4BAA4B,2BAA2B,CAAC;AACxD,MAAA,wBAAwB,2BAA2B,CAAC;AAEjE,MAAM,wBAAwBA,iCAA8D,sBAAsB;AAErG,MAAA,uBAAuB,sBAAsB,CAAC;AAC9C,MAAA,mBAAmB,sBAAsB,CAAC;;;;;;;;;"}
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;;;;;;;;;"}
@@ -1 +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\n\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;AAE/F,MAAA,+BAA+B,8BAA8B,CAAC;AAC9D,MAAA,2BAA2B,8BAA8B,CAAC;AAIvE,MAAM,2BAA2B,sBAA2D,yBAAyB;AAExG,MAAA,0BAA0B,yBAAyB,CAAC;AACpD,MAAA,sBAAsB,yBAAyB,CAAC;AAG7D,MAAM,6BAA6B,sBAAqC,2BAA2B;AAEtF,MAAA,4BAA4B,2BAA2B,CAAC;AACxD,MAAA,wBAAwB,2BAA2B,CAAC;AAEjE,MAAM,wBAAwB,sBAA8D,sBAAsB;AAErG,MAAA,uBAAuB,sBAAsB,CAAC;AAC9C,MAAA,mBAAmB,sBAAsB,CAAC;"}
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;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectDataView.d.ts","sourceRoot":"","sources":["../../../src/components/SelectDataView.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAW,MAAM,OAAO,CAAA;AAEjD,OAAO,EAAE,aAAa,EAA2C,MAAM,2BAA2B,CAAA;AAElG,MAAM,MAAM,mBAAmB,GAC5B,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAC/B;IACD,QAAQ,EAAE,SAAS,CAAA;CACnB,CAAA;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CAcxD,CAAA"}
1
+ {"version":3,"file":"SelectDataView.d.ts","sourceRoot":"","sources":["../../../src/components/SelectDataView.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAW,MAAM,OAAO,CAAA;AAEjD,OAAO,EAA2C,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAElG,MAAM,MAAM,mBAAmB,GAC5B,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAC/B;IACD,QAAQ,EAAE,SAAS,CAAA;CACnB,CAAA;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CAcxD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectEachItem.d.ts","sourceRoot":"","sources":["../../../src/components/SelectEachItem.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKxC,eAAO,MAAM,eAAe,GAAI,cAAc;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,8CAOpE,CAAA"}
1
+ {"version":3,"file":"SelectEachItem.d.ts","sourceRoot":"","sources":["../../../src/components/SelectEachItem.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIxC,eAAO,MAAM,eAAe,GAAI,cAAc;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,8CAOpE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectNewItem.d.ts","sourceRoot":"","sources":["../../../src/components/SelectNewItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAA;AAG/D,eAAO,MAAM,aAAa,GAAI,cAAc;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,mDAgDlE,CAAA"}
1
+ {"version":3,"file":"SelectNewItem.d.ts","sourceRoot":"","sources":["../../../src/components/SelectNewItem.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAA;AAG/D,eAAO,MAAM,aAAa,GAAI,cAAc;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,mDAuDlE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SortableMultiSelect.d.ts","sourceRoot":"","sources":["../../../src/components/SortableMultiSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAA;AAE9D,OAAO,EAQN,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAE1B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,MAAM,wBAAwB,GACjC;IACD,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAA;IACzC,OAAO,CAAC,EAAE,0BAA0B,CAAC,UAAU,CAAC,CAAA;IAChD,UAAU,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAA;IAC/C,SAAS,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAA;CAC/C,GACC,YAAY,CAAA;AAEf,eAAO,MAAM,mBAAmB;cARpB,SAAS;WACZ,yBAAyB,CAAC,OAAO,CAAC;cAC/B,0BAA0B,CAAC,UAAU,CAAC;gBACpC,0BAA0B,CAAC,OAAO,CAAC;eACpC,2BAA2B,CAAC,OAAO,CAAC;iBAmE/C,CAAA"}
1
+ {"version":3,"file":"SortableMultiSelect.d.ts","sourceRoot":"","sources":["../../../src/components/SortableMultiSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAA;AAE9D,OAAO,EAWN,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAE1B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,MAAM,wBAAwB,GACjC;IACD,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAA;IACzC,OAAO,CAAC,EAAE,0BAA0B,CAAC,UAAU,CAAC,CAAA;IAChD,UAAU,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAA;IAC/C,SAAS,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAA;CAC/C,GACC,YAAY,CAAA;AAEf,eAAO,MAAM,mBAAmB;cARpB,SAAS;WACZ,yBAAyB,CAAC,OAAO,CAAC;cAC/B,0BAA0B,CAAC,UAAU,CAAC;gBACpC,0BAA0B,CAAC,OAAO,CAAC;eACpC,2BAA2B,CAAC,OAAO,CAAC;iBAqEhD,CAAA"}
@@ -11,13 +11,13 @@ export declare const SelectHandleSelectContext: import("react").Context<SelectHa
11
11
  export declare const useSelectHandleSelect: () => SelectHandler;
12
12
  /** @internal */
13
13
  export declare const SelectOptionsContext: import("react").Context<string | {
14
- filter?: import("@contember/react-binding").SugaredFilter;
15
- hasOneRelationPath?: import("@contember/react-binding").SugarableHasOneRelation[] | import("@contember/react-binding").SugarableHasOneRelation;
16
- entityName: import("@contember/react-binding").EntityName;
14
+ filter?: import("@contember/binding-common").SugaredFilter;
15
+ hasOneRelationPath?: import("@contember/binding-common").SugarableHasOneRelation[] | import("@contember/binding-common").SugarableHasOneRelation;
16
+ entityName: import("@contember/binding-common").EntityName;
17
17
  }>;
18
18
  export declare const useSelectOptions: () => string | {
19
- filter?: import("@contember/react-binding").SugaredFilter;
20
- hasOneRelationPath?: import("@contember/react-binding").SugarableHasOneRelation[] | import("@contember/react-binding").SugarableHasOneRelation;
21
- entityName: import("@contember/react-binding").EntityName;
19
+ filter?: import("@contember/binding-common").SugaredFilter;
20
+ hasOneRelationPath?: import("@contember/binding-common").SugarableHasOneRelation[] | import("@contember/binding-common").SugarableHasOneRelation;
21
+ entityName: import("@contember/binding-common").EntityName;
22
22
  };
23
23
  //# sourceMappingURL=contexts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/contexts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAA8B,MAAM,0BAA0B,CAAA;AAIrF,gBAAgB;AAChB,eAAO,MAAM,4BAA4B,2CAAmC,CAAA;AAC5E,eAAO,MAAM,wBAAwB,wBAAmC,CAAA;AAKxE,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,mCAF4B,cAAc,KAAK,OAAO,CAExB,CAAA;AAClE,eAAO,MAAM,mBAAmB,iBAHgC,cAAc,KAAK,OAGrB,CAAA;AAE9D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,KAAK,IAAI,CAAA;AAEvG,gBAAgB;AAChB,eAAO,MAAM,yBAAyB,wCAAgC,CAAA;AACtE,eAAO,MAAM,qBAAqB,qBAAgC,CAAA;AAGlE,gBAAgB;AAChB,eAAO,MAAM,oBAAoB;;;;EAA2B,CAAA;AAC5D,eAAO,MAAM,gBAAgB;;;;CAA2B,CAAA"}
1
+ {"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/contexts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAA8B,MAAM,0BAA0B,CAAA;AAIrF,gBAAgB;AAChB,eAAO,MAAM,4BAA4B,2CAAmC,CAAA;AAC5E,eAAO,MAAM,wBAAwB,wBAAmC,CAAA;AAGxE,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,mCAF4B,cAAc,KAAK,OAAO,CAExB,CAAA;AAClE,eAAO,MAAM,mBAAmB,iBAHgC,cAAc,KAAK,OAGrB,CAAA;AAE9D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,KAAK,IAAI,CAAA;AAEvG,gBAAgB;AAChB,eAAO,MAAM,yBAAyB,wCAAgC,CAAA;AACtE,eAAO,MAAM,qBAAqB,qBAAgC,CAAA;AAGlE,gBAAgB;AAChB,eAAO,MAAM,oBAAoB;;;;EAA2B,CAAA;AAC5D,eAAO,MAAM,gBAAgB;;;;CAA2B,CAAA"}