@contember/react-select 2.1.0-alpha.30 → 2.1.0-alpha.36
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/package.json +12 -12
- package/src/components/MultiSelect.tsx +1 -2
- package/src/components/Select.tsx +0 -1
- package/src/components/SelectDataView.tsx +1 -1
- package/src/components/SelectEachItem.tsx +0 -1
- package/src/components/SelectItemTrigger.tsx +1 -1
- package/src/components/SelectNewItem.tsx +27 -10
- package/src/components/SortableMultiSelect.tsx +64 -60
- package/src/contexts.ts +0 -2
- package/dist/development/index.cjs +0 -30
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -30
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/components/MultiSelect.cjs +0 -54
- package/dist/development/src/components/MultiSelect.cjs.map +0 -1
- package/dist/development/src/components/MultiSelect.js +0 -54
- package/dist/development/src/components/MultiSelect.js.map +0 -1
- package/dist/development/src/components/Select.cjs +0 -52
- package/dist/development/src/components/Select.cjs.map +0 -1
- package/dist/development/src/components/Select.js +0 -52
- package/dist/development/src/components/Select.js.map +0 -1
- package/dist/development/src/components/SelectDataView.cjs +0 -30
- package/dist/development/src/components/SelectDataView.cjs.map +0 -1
- package/dist/development/src/components/SelectDataView.js +0 -30
- package/dist/development/src/components/SelectDataView.js.map +0 -1
- package/dist/development/src/components/SelectEachItem.cjs +0 -15
- package/dist/development/src/components/SelectEachItem.cjs.map +0 -1
- package/dist/development/src/components/SelectEachItem.js +0 -15
- package/dist/development/src/components/SelectEachItem.js.map +0 -1
- package/dist/development/src/components/SelectItemTrigger.cjs +0 -23
- package/dist/development/src/components/SelectItemTrigger.cjs.map +0 -1
- package/dist/development/src/components/SelectItemTrigger.js +0 -23
- package/dist/development/src/components/SelectItemTrigger.js.map +0 -1
- package/dist/development/src/components/SelectNewItem.cjs +0 -60
- package/dist/development/src/components/SelectNewItem.cjs.map +0 -1
- package/dist/development/src/components/SelectNewItem.js +0 -60
- package/dist/development/src/components/SelectNewItem.js.map +0 -1
- package/dist/development/src/components/SelectOption.cjs +0 -30
- package/dist/development/src/components/SelectOption.cjs.map +0 -1
- package/dist/development/src/components/SelectOption.js +0 -30
- package/dist/development/src/components/SelectOption.js.map +0 -1
- package/dist/development/src/components/SelectPlaceholder.cjs +0 -14
- package/dist/development/src/components/SelectPlaceholder.cjs.map +0 -1
- package/dist/development/src/components/SelectPlaceholder.js +0 -14
- package/dist/development/src/components/SelectPlaceholder.js.map +0 -1
- package/dist/development/src/components/SortableMultiSelect.cjs +0 -78
- package/dist/development/src/components/SortableMultiSelect.cjs.map +0 -1
- package/dist/development/src/components/SortableMultiSelect.js +0 -78
- package/dist/development/src/components/SortableMultiSelect.js.map +0 -1
- package/dist/development/src/contexts.cjs +0 -24
- package/dist/development/src/contexts.cjs.map +0 -1
- package/dist/development/src/contexts.js +0 -24
- package/dist/development/src/contexts.js.map +0 -1
- package/dist/production/index.cjs +0 -30
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -30
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/components/MultiSelect.cjs +0 -34
- package/dist/production/src/components/MultiSelect.cjs.map +0 -1
- package/dist/production/src/components/MultiSelect.js +0 -34
- package/dist/production/src/components/MultiSelect.js.map +0 -1
- package/dist/production/src/components/Select.cjs +0 -32
- package/dist/production/src/components/Select.cjs.map +0 -1
- package/dist/production/src/components/Select.js +0 -32
- package/dist/production/src/components/Select.js.map +0 -1
- package/dist/production/src/components/SelectDataView.cjs +0 -22
- package/dist/production/src/components/SelectDataView.cjs.map +0 -1
- package/dist/production/src/components/SelectDataView.js +0 -22
- package/dist/production/src/components/SelectDataView.js.map +0 -1
- package/dist/production/src/components/SelectEachItem.cjs +0 -11
- package/dist/production/src/components/SelectEachItem.cjs.map +0 -1
- package/dist/production/src/components/SelectEachItem.js +0 -11
- package/dist/production/src/components/SelectEachItem.js.map +0 -1
- package/dist/production/src/components/SelectItemTrigger.cjs +0 -19
- package/dist/production/src/components/SelectItemTrigger.cjs.map +0 -1
- package/dist/production/src/components/SelectItemTrigger.js +0 -19
- package/dist/production/src/components/SelectItemTrigger.js.map +0 -1
- package/dist/production/src/components/SelectNewItem.cjs +0 -40
- package/dist/production/src/components/SelectNewItem.cjs.map +0 -1
- package/dist/production/src/components/SelectNewItem.js +0 -40
- package/dist/production/src/components/SelectNewItem.js.map +0 -1
- package/dist/production/src/components/SelectOption.cjs +0 -22
- package/dist/production/src/components/SelectOption.cjs.map +0 -1
- package/dist/production/src/components/SelectOption.js +0 -22
- package/dist/production/src/components/SelectOption.js.map +0 -1
- package/dist/production/src/components/SelectPlaceholder.cjs +0 -10
- package/dist/production/src/components/SelectPlaceholder.cjs.map +0 -1
- package/dist/production/src/components/SelectPlaceholder.js +0 -10
- package/dist/production/src/components/SelectPlaceholder.js.map +0 -1
- package/dist/production/src/components/SortableMultiSelect.cjs +0 -50
- package/dist/production/src/components/SortableMultiSelect.cjs.map +0 -1
- package/dist/production/src/components/SortableMultiSelect.js +0 -50
- package/dist/production/src/components/SortableMultiSelect.js.map +0 -1
- package/dist/production/src/contexts.cjs +0 -24
- package/dist/production/src/contexts.cjs.map +0 -1
- package/dist/production/src/contexts.js +0 -24
- package/dist/production/src/contexts.js.map +0 -1
- package/dist/types/components/MultiSelect.d.ts +0 -14
- package/dist/types/components/MultiSelect.d.ts.map +0 -1
- package/dist/types/components/Select.d.ts +0 -16
- package/dist/types/components/Select.d.ts.map +0 -1
- package/dist/types/components/SelectDataView.d.ts +0 -7
- package/dist/types/components/SelectDataView.d.ts.map +0 -1
- package/dist/types/components/SelectEachItem.d.ts +0 -5
- package/dist/types/components/SelectEachItem.d.ts.map +0 -1
- package/dist/types/components/SelectItemTrigger.d.ts +0 -8
- package/dist/types/components/SelectItemTrigger.d.ts.map +0 -1
- package/dist/types/components/SelectNewItem.d.ts +0 -5
- package/dist/types/components/SelectNewItem.d.ts.map +0 -1
- package/dist/types/components/SelectOption.d.ts +0 -7
- package/dist/types/components/SelectOption.d.ts.map +0 -1
- package/dist/types/components/SelectPlaceholder.d.ts +0 -5
- package/dist/types/components/SelectPlaceholder.d.ts.map +0 -1
- package/dist/types/components/SortableMultiSelect.d.ts +0 -18
- package/dist/types/components/SortableMultiSelect.d.ts.map +0 -1
- package/dist/types/components/index.d.ts +0 -10
- package/dist/types/components/index.d.ts.map +0 -1
- package/dist/types/contexts.d.ts +0 -23
- package/dist/types/contexts.d.ts.map +0 -1
- package/dist/types/hooks/index.d.ts +0 -2
- package/dist/types/hooks/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/types/events.d.ts +0 -6
- package/dist/types/types/events.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -2
- package/dist/types/types/index.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/react-select",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.1.0-alpha.
|
|
4
|
+
"version": "2.1.0-alpha.36",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -30,23 +30,23 @@
|
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/contember/
|
|
33
|
+
"url": "git+https://github.com/contember/contember.git",
|
|
34
34
|
"directory": "packages/react-select"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@contember/react-binding": "
|
|
38
|
-
"@contember/react-dataview": "
|
|
39
|
-
"@contember/react-repeater": "
|
|
40
|
-
"@contember/react-utils": "
|
|
41
|
-
"@contember/utilities": "
|
|
42
|
-
"@radix-ui/react-slot": "
|
|
37
|
+
"@contember/react-binding": "workspace:*",
|
|
38
|
+
"@contember/react-dataview": "workspace:*",
|
|
39
|
+
"@contember/react-repeater": "workspace:*",
|
|
40
|
+
"@contember/react-utils": "workspace:*",
|
|
41
|
+
"@contember/utilities": "workspace:*",
|
|
42
|
+
"@radix-ui/react-slot": "catalog:"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"react": "
|
|
46
|
-
"react-dom": "
|
|
45
|
+
"react": "catalog:",
|
|
46
|
+
"react-dom": "catalog:"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"react": "
|
|
50
|
-
"react-dom": "
|
|
49
|
+
"react": "catalog:",
|
|
50
|
+
"react-dom": "catalog:"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -16,7 +16,7 @@ export const MultiSelect = Component(({ field, children, options, onSelect, onUn
|
|
|
16
16
|
const entities = useEntityList({ field })
|
|
17
17
|
options ??= entities.name
|
|
18
18
|
const entitiesArr = useMemo(() => Array.from(entities), [entities])
|
|
19
|
-
const selectedEntities = useMemo(() => Array.from(entities).map(it => it.id), [entities])
|
|
19
|
+
const selectedEntities = useMemo(() => Array.from(entities).map((it: EntityAccessor) => it.id), [entities])
|
|
20
20
|
|
|
21
21
|
const handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {
|
|
22
22
|
const isSelected = selectedEntities.includes(entity.id)
|
|
@@ -53,4 +53,3 @@ export const MultiSelect = Component(({ field, children, options, onSelect, onUn
|
|
|
53
53
|
</HasMany>
|
|
54
54
|
)
|
|
55
55
|
})
|
|
56
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode, useMemo } from 'react'
|
|
2
2
|
import { useSelectHandleSelect, useSelectOptions } from '../contexts'
|
|
3
|
-
import {
|
|
3
|
+
import { DataView, DataViewFilterHandlerRegistry, DataViewProps } from '@contember/react-dataview'
|
|
4
4
|
|
|
5
5
|
export type SelectDataViewProps =
|
|
6
6
|
& Omit<DataViewProps, 'entities'>
|
|
@@ -2,7 +2,6 @@ import React, { ReactNode } from 'react'
|
|
|
2
2
|
import { useSelectCurrentEntities } from '../contexts'
|
|
3
3
|
import { Entity } from '@contember/react-binding'
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
export const SelectEachValue = ({ children }: { children: ReactNode }) => {
|
|
7
6
|
const entities = useSelectCurrentEntities()
|
|
8
7
|
return entities.map(entity => (
|
|
@@ -17,5 +17,5 @@ export const SelectItemTrigger = forwardRef<HTMLElement, SelectItemTriggerProps>
|
|
|
17
17
|
handleSelect?.(entity, action)
|
|
18
18
|
onClickProp?.(e)
|
|
19
19
|
}, [action, entity, handleSelect, onClickProp])
|
|
20
|
-
return <Slot {...props} onClick={onClick}
|
|
20
|
+
return <Slot {...props} onClick={onClick} ref={ref} />
|
|
21
21
|
})
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
EntityAccessor,
|
|
4
|
+
EntitySubTree,
|
|
5
|
+
QueryLanguage,
|
|
6
|
+
TreeRootId,
|
|
7
|
+
TreeRootIdProvider,
|
|
8
|
+
useEnvironment,
|
|
9
|
+
useExtendTree,
|
|
10
|
+
useGetEntitySubTree,
|
|
11
|
+
} from '@contember/react-binding'
|
|
2
12
|
import * as React from 'react'
|
|
3
13
|
import { ReactNode, useEffect, useMemo, useState } from 'react'
|
|
4
14
|
import { useSelectOptions } from '../contexts'
|
|
@@ -6,21 +16,28 @@ import { useSelectOptions } from '../contexts'
|
|
|
6
16
|
export const SelectNewItem = ({ children }: { children: ReactNode }) => {
|
|
7
17
|
const options = useSelectOptions()
|
|
8
18
|
const env = useEnvironment()
|
|
9
|
-
const { entityName } = useMemo((
|
|
19
|
+
const { entityName } = useMemo(() => QueryLanguage.desugarQualifiedEntityList({ entities: options }, env), [env, options])
|
|
10
20
|
|
|
11
21
|
const [state, setState] = useState<{ entity: EntityAccessor; treeRootId: TreeRootId } | null>(null)
|
|
12
22
|
const extendTree = useExtendTree()
|
|
13
23
|
const getSubTree = useGetEntitySubTree()
|
|
14
24
|
|
|
15
25
|
useEffect(() => {
|
|
16
|
-
(async () => {
|
|
17
|
-
const treeRootId = await extendTree(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
;(async () => {
|
|
27
|
+
const treeRootId = await extendTree(
|
|
28
|
+
<>
|
|
29
|
+
<EntitySubTree
|
|
30
|
+
entity={{
|
|
31
|
+
entityName,
|
|
32
|
+
}}
|
|
33
|
+
expectedMutation={'none'}
|
|
34
|
+
isUnpersisted
|
|
35
|
+
isCreating
|
|
36
|
+
>
|
|
37
|
+
{children}
|
|
38
|
+
</EntitySubTree>
|
|
39
|
+
</>,
|
|
40
|
+
)
|
|
24
41
|
if (!treeRootId) {
|
|
25
42
|
return
|
|
26
43
|
}
|
|
@@ -3,9 +3,12 @@ import { SelectCurrentEntitiesContext, SelectHandler, SelectHandleSelectContext,
|
|
|
3
3
|
import {
|
|
4
4
|
Component,
|
|
5
5
|
EntityAccessor,
|
|
6
|
+
EntityListSubTreeMarker,
|
|
7
|
+
EntitySubTreeMarker,
|
|
6
8
|
FieldMarker,
|
|
9
|
+
HasManyRelationMarker,
|
|
7
10
|
HasOne,
|
|
8
|
-
|
|
11
|
+
HasOneRelationMarker,
|
|
9
12
|
PlaceholderGenerator,
|
|
10
13
|
QueryLanguage,
|
|
11
14
|
SugaredQualifiedEntityList,
|
|
@@ -28,68 +31,69 @@ export type SortableMultiSelectProps =
|
|
|
28
31
|
}
|
|
29
32
|
& SelectEvents
|
|
30
33
|
|
|
31
|
-
export const SortableMultiSelect = Component(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
export const SortableMultiSelect = Component(
|
|
35
|
+
({ field, children, sortableBy, connectAt, options, onSelect, onUnselect }: SortableMultiSelectProps) => {
|
|
36
|
+
const list = useEntityList({ field })
|
|
37
|
+
const entitiesArr = useMemo(() => Array.from(list), [list])
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const optionsMarker = useMemo(() => {
|
|
40
|
+
const desugared = QueryLanguage.desugarRelativeSingleEntity({ field: connectAt }, list.environment)
|
|
41
|
+
let marker: HasOneRelationMarker | HasManyRelationMarker | EntitySubTreeMarker | EntityListSubTreeMarker = list.getMarker()
|
|
42
|
+
for (let relation of desugared.hasOneRelationPath) {
|
|
43
|
+
const placeholder = PlaceholderGenerator.getHasOneRelationPlaceholder(relation)
|
|
44
|
+
const relationMarker = marker.fields.markers.get(placeholder)
|
|
45
|
+
if (!relationMarker || relationMarker instanceof FieldMarker) {
|
|
46
|
+
throw new Error('Invalid marker')
|
|
47
|
+
}
|
|
48
|
+
marker = relationMarker
|
|
43
49
|
}
|
|
44
|
-
marker
|
|
45
|
-
}
|
|
46
|
-
return marker
|
|
47
|
-
}, [connectAt, list])
|
|
50
|
+
return marker
|
|
51
|
+
}, [connectAt, list])
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
options ??= optionsMarker.environment.getSubTreeNode().entity.name
|
|
50
54
|
|
|
55
|
+
const selectedEntities = useMemo(() => Array.from(list).map((it: EntityAccessor) => it.getEntity({ field: connectAt }).id), [connectAt, list])
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
action
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return selectedEntities.includes(entity.id)
|
|
71
|
-
}, [selectedEntities])
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>
|
|
75
|
-
<SelectCurrentEntitiesContext.Provider value={entitiesArr}>
|
|
76
|
-
<SelectIsSelectedContext.Provider value={isSelected}>
|
|
77
|
-
<SelectHandleSelectContext.Provider value={handler}>
|
|
78
|
-
<SelectOptionsContext.Provider value={options}>
|
|
79
|
-
{children}
|
|
80
|
-
</SelectOptionsContext.Provider>
|
|
81
|
-
</SelectHandleSelectContext.Provider>
|
|
82
|
-
</SelectIsSelectedContext.Provider>
|
|
83
|
-
</SelectCurrentEntitiesContext.Provider>
|
|
84
|
-
</Repeater>
|
|
85
|
-
)
|
|
86
|
-
}, ({ children, field, sortableBy, connectAt }) => {
|
|
87
|
-
return (
|
|
88
|
-
<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>
|
|
89
|
-
<HasOne field={connectAt} expectedMutation="connectOrDisconnect">
|
|
90
|
-
{children}
|
|
91
|
-
</HasOne>
|
|
92
|
-
</Repeater>
|
|
93
|
-
)
|
|
94
|
-
})
|
|
57
|
+
const handler = useReferentiallyStableCallback<SelectHandler>((entity, action = 'toggle') => {
|
|
58
|
+
const isSelected = selectedEntities.includes(entity.id)
|
|
59
|
+
if (action === 'toggle') {
|
|
60
|
+
action = isSelected ? 'unselect' : 'select'
|
|
61
|
+
}
|
|
62
|
+
if (action === 'unselect' && isSelected) {
|
|
63
|
+
Array.from(list).find((it: EntityAccessor) => it.getEntity({ field: connectAt }).id === entity.id)?.deleteEntity()
|
|
64
|
+
onUnselect?.(entity)
|
|
65
|
+
} else if (action === 'select' && !isSelected) {
|
|
66
|
+
list.createNewEntity(getEntity => {
|
|
67
|
+
getEntity().connectEntityAtField({ field: connectAt }, entity)
|
|
68
|
+
onSelect?.(entity)
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
const isSelected = useCallback((entity: EntityAccessor) => {
|
|
73
|
+
return selectedEntities.includes(entity.id)
|
|
74
|
+
}, [selectedEntities])
|
|
95
75
|
|
|
76
|
+
return (
|
|
77
|
+
<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>
|
|
78
|
+
<SelectCurrentEntitiesContext.Provider value={entitiesArr}>
|
|
79
|
+
<SelectIsSelectedContext.Provider value={isSelected}>
|
|
80
|
+
<SelectHandleSelectContext.Provider value={handler}>
|
|
81
|
+
<SelectOptionsContext.Provider value={options}>
|
|
82
|
+
{children}
|
|
83
|
+
</SelectOptionsContext.Provider>
|
|
84
|
+
</SelectHandleSelectContext.Provider>
|
|
85
|
+
</SelectIsSelectedContext.Provider>
|
|
86
|
+
</SelectCurrentEntitiesContext.Provider>
|
|
87
|
+
</Repeater>
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
({ children, field, sortableBy, connectAt }) => {
|
|
91
|
+
return (
|
|
92
|
+
<Repeater field={field} sortableBy={sortableBy} initialEntityCount={0}>
|
|
93
|
+
<HasOne field={connectAt} expectedMutation="connectOrDisconnect">
|
|
94
|
+
{children}
|
|
95
|
+
</HasOne>
|
|
96
|
+
</Repeater>
|
|
97
|
+
)
|
|
98
|
+
},
|
|
99
|
+
)
|
package/src/contexts.ts
CHANGED
|
@@ -7,8 +7,6 @@ const _SelectCurrentEntitiesContext = createRequiredContext<EntityAccessor[]>('S
|
|
|
7
7
|
export const SelectCurrentEntitiesContext = _SelectCurrentEntitiesContext[0]
|
|
8
8
|
export const useSelectCurrentEntities = _SelectCurrentEntitiesContext[1]
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
const _SelectIsSelectedContext = createRequiredContext<(entity: EntityAccessor) => boolean>('SelectIsSelectedContext')
|
|
13
11
|
/** @internal */
|
|
14
12
|
export const SelectIsSelectedContext = _SelectIsSelectedContext[0]
|
|
@@ -1,30 +0,0 @@
|
|
|
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 SelectNewItem = require("./src/components/SelectNewItem.cjs");
|
|
7
|
-
const SelectDataView = require("./src/components/SelectDataView.cjs");
|
|
8
|
-
const SelectEachItem = require("./src/components/SelectEachItem.cjs");
|
|
9
|
-
const SelectItemTrigger = require("./src/components/SelectItemTrigger.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.SelectNewItem = SelectNewItem.SelectNewItem;
|
|
24
|
-
exports.SelectDataView = SelectDataView.SelectDataView;
|
|
25
|
-
exports.SelectEachValue = SelectEachItem.SelectEachValue;
|
|
26
|
-
exports.SelectItemTrigger = SelectItemTrigger.SelectItemTrigger;
|
|
27
|
-
exports.SelectOption = SelectOption.SelectOption;
|
|
28
|
-
exports.SelectPlaceholder = SelectPlaceholder.SelectPlaceholder;
|
|
29
|
-
exports.SortableMultiSelect = SortableMultiSelect.SortableMultiSelect;
|
|
30
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,30 +0,0 @@
|
|
|
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 { SelectNewItem } from "./src/components/SelectNewItem.js";
|
|
5
|
-
import { SelectDataView } from "./src/components/SelectDataView.js";
|
|
6
|
-
import { SelectEachValue } from "./src/components/SelectEachItem.js";
|
|
7
|
-
import { SelectItemTrigger } from "./src/components/SelectItemTrigger.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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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 => 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\n"],"names":["Component","useEntityList","useMemo","useReferentiallyStableCallback","isSelected","useCallback","jsxDEV","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","this","HasMany"],"m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AA,cAAA;AAAA,EAAA,GAAAA,MAIA,EALD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA,EAPD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAQA,GAAAA,MAAA;AAEF,GAAG,CAAC,EAAE,OAAO,eAAe;AAC3B,SACEL,8BAAA,OAAAM,sBAAA,EAAQ,OAAc,kBAAiB,uBACtC,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAEA,GAAAD,MAAA;AAEF,CAAC;;"}
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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 => 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\n"],"names":["isSelected","this"],"mappings":";;;;;AAca,MAAA,cAAc,UAAU,CAAC,EAAE,OAAO,UAAU,SAAS,UAAU,iBAAmC;AAC9G,QAAM,WAAW,cAAc,EAAE,OAAO;AACxC,cAAA,UAAY,SAAS;AACf,QAAA,cAAc,QAAQ,MAAM,MAAM,KAAK,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAClE,QAAM,mBAAmB,QAAQ,MAAM,MAAM,KAAK,QAAQ,EAAE,IAAI,CAAA,OAAM,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC;AAExF,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,eAAS,iBAAiB,MAAM;AAChC,mBAAa,MAAM;AAAA,IACT,WAAA,WAAW,YAAY,CAACA,aAAY;AAC9C,eAAS,cAAc,MAAM;AAC7B,iBAAW,MAAM;AAAA,IAAA;AAAA,EAClB,CACA;AACK,QAAA,aAAa,YAAY,CAAC,WAA2B;AACnD,WAAA,iBAAiB,SAAS,OAAO,EAAE;AAAA,EAAA,GACxC,CAAC,gBAAgB,CAAC;AAGpB,SAAA,uBAAC,6BAA6B,UAA7B,EAAsC,OAAO,aAC7C,UAAC,uBAAA,wBAAwB,UAAxB,EAAiC,OAAO,YACxC,iCAAC,0BAA0B,UAA1B,EAAmC,OAAO,SAC1C,UAAA,uBAAC,qBAAqB,UAArB,EAA8B,OAAO,SACpC,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EALD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA,EAPD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAQA,GAAAA,MAAA;AAEF,GAAG,CAAC,EAAE,OAAO,eAAe;AAC3B,SACE,uBAAA,SAAA,EAAQ,OAAc,kBAAiB,uBACtC,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAEA,GAAAA,MAAA;AAEF,CAAC;"}
|
|
@@ -1,52 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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\n"],"names":["Component","useEntity","useMemo","useReferentiallyStableCallback","useCallback","entity","jsxDEV","SelectCurrentEntitiesContext","SelectIsSelectedContext","SelectHandleSelectContext","SelectOptionsContext","this","HasOne"],"mappings":";;;;;;;AAea,MAAA,SAASA,aAAAA,UAAU,CAAC,EAAE,OAAO,UAAU,YAAY,UAAU,cAA2B;AACpG,QAAM,SAASC,aAAAA,UAAU;AACzB,QAAM,iBAAiB,OAAO,UAAU,EAAE,OAAO;AACjD,cAAA,UAAY,eAAe;AAErB,QAAA,eAAe,eAAe,kBAAkB,eAAe;AACrE,QAAM,cAAcC,cAAQ,MAAM,eAAe,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,cAAc,CAAC;AAEtG,QAAM,eAAeC,WAAA,+BAA8C,CAAC,UAAU,SAAS,aAAa;AACnG,QAAI,WAAW,UAAU;AACxB,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,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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\n"],"names":["entity","this"],"mappings":";;;;;AAea,MAAA,SAAS,UAAU,CAAC,EAAE,OAAO,UAAU,YAAY,UAAU,cAA2B;AACpG,QAAM,SAAS,UAAU;AACz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