@rokkit/core 1.0.0-next.18 → 1.0.0-next.19
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 +5 -2
- package/src/DropDown.svelte +1 -1
- package/src/NestedList.svelte +9 -7
- package/src/items/Node.svelte +23 -10
- package/src/lib/connector.js +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.19",
|
|
4
4
|
"description": "Core components, actions and stores for svelte apps.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"svelte": "^3.58.0",
|
|
26
26
|
"typescript": "^4.9.5",
|
|
27
27
|
"validators": "latest",
|
|
28
|
-
"vite": "^4.3.
|
|
28
|
+
"vite": "^4.3.3",
|
|
29
29
|
"vitest": "~0.19.1",
|
|
30
30
|
"shared-config": "1.0.0"
|
|
31
31
|
},
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"import": "./src/index.js"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"ramda": "^0.28.0"
|
|
51
|
+
},
|
|
49
52
|
"scripts": {
|
|
50
53
|
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
|
|
51
54
|
"format": "prettier --write --plugin-search-dir=. .",
|
package/src/DropDown.svelte
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
37
37
|
<drop-down
|
|
38
|
-
class="flex
|
|
38
|
+
class="flex relative cursor-pointer select-none dropdown {className}"
|
|
39
39
|
class:open
|
|
40
40
|
tabindex="0"
|
|
41
41
|
aria-haspopup="true"
|
package/src/NestedList.svelte
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { Node, Text } from './items'
|
|
3
3
|
import { defaultFields } from './constants'
|
|
4
|
+
import { getLineTypes } from './lib/connector'
|
|
4
5
|
|
|
5
6
|
let className = 'list'
|
|
6
7
|
export { className as class }
|
|
@@ -9,7 +10,7 @@
|
|
|
9
10
|
export let using = {}
|
|
10
11
|
export let types = []
|
|
11
12
|
export let value = null
|
|
12
|
-
export let linesVisible = true
|
|
13
|
+
// export let linesVisible = true
|
|
13
14
|
export let rtl = false
|
|
14
15
|
export let hierarchy = []
|
|
15
16
|
export let icons
|
|
@@ -45,22 +46,24 @@
|
|
|
45
46
|
on:collapse={handle}
|
|
46
47
|
> -->
|
|
47
48
|
{#each items as content, index}
|
|
48
|
-
{@const type = nodeTypes[index] === 'middle' ? 'line' : 'empty'}
|
|
49
|
+
<!-- {@const type = nodeTypes[index] === 'middle' ? 'line' : 'empty'} -->
|
|
49
50
|
{@const hasChildren = fields.children in content}
|
|
50
|
-
{@const connectors =
|
|
51
|
+
<!-- {@const connectors = types.slice(0, -1)} -->
|
|
51
52
|
{@const path = [...hierarchy, index]}
|
|
53
|
+
{@const connectors = getLineTypes(hasChildren, types, nodeTypes[index])}
|
|
52
54
|
|
|
55
|
+
<!-- types={[...connectors, nodeTypes[index]]} -->
|
|
53
56
|
<Node
|
|
54
57
|
bind:content
|
|
55
58
|
{fields}
|
|
56
59
|
{using}
|
|
57
|
-
types={
|
|
58
|
-
{linesVisible}
|
|
60
|
+
types={connectors}
|
|
59
61
|
{rtl}
|
|
60
62
|
{path}
|
|
61
63
|
stateIcons={icons}
|
|
62
64
|
selected={value === content}
|
|
63
65
|
/>
|
|
66
|
+
<!-- types={[...connectors, type, nodeTypes[index]]} -->
|
|
64
67
|
{#if hasChildren && content[fields.isOpen]}
|
|
65
68
|
<svelte:self
|
|
66
69
|
items={content[fields.children]}
|
|
@@ -68,8 +71,7 @@
|
|
|
68
71
|
{fields}
|
|
69
72
|
{using}
|
|
70
73
|
{icons}
|
|
71
|
-
types={
|
|
72
|
-
{linesVisible}
|
|
74
|
+
types={connectors}
|
|
73
75
|
hierarchy={path}
|
|
74
76
|
/>
|
|
75
77
|
{/if}
|
package/src/items/Node.svelte
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import Connector from './Connector.svelte'
|
|
3
3
|
import { defaultFields, defaultStateIcons } from '../constants'
|
|
4
|
-
import {
|
|
4
|
+
// import { getLineTypes } from '../lib/connector'
|
|
5
|
+
// import { has } from 'ramda'
|
|
6
|
+
// import { createEventDispatcher } from 'svelte'
|
|
5
7
|
|
|
6
|
-
const dispatch = createEventDispatcher()
|
|
8
|
+
// const dispatch = createEventDispatcher()
|
|
7
9
|
export let content
|
|
8
10
|
export let fields = defaultFields
|
|
9
11
|
export let types = []
|
|
10
12
|
export let stateIcons = defaultStateIcons.node
|
|
11
|
-
export let linesVisible = true
|
|
13
|
+
// export let linesVisible = true
|
|
12
14
|
export let selected = false
|
|
13
15
|
export let using = {}
|
|
14
16
|
export let rtl = false
|
|
@@ -23,7 +25,8 @@
|
|
|
23
25
|
$: component = content[fields.component]
|
|
24
26
|
? using[content[fields.component]] || using.default
|
|
25
27
|
: using.default
|
|
26
|
-
|
|
28
|
+
// $: types = [...types, ...(hasChildren ? [] : ['empty'])]
|
|
29
|
+
// $: types = getLineTypes(hasChildren, types)
|
|
27
30
|
// function toggle() {
|
|
28
31
|
// if (hasChildren) content[fields.isOpen] = !content[fields.isOpen]
|
|
29
32
|
// dispatch('select', content)
|
|
@@ -40,15 +43,25 @@
|
|
|
40
43
|
role="option"
|
|
41
44
|
data-path={path.join(',')}
|
|
42
45
|
>
|
|
43
|
-
{#each types
|
|
44
|
-
|
|
46
|
+
{#each types as type}
|
|
47
|
+
{#if type === 'icon'}
|
|
48
|
+
<span class="flex flex-col w-4 h-full items-center justify-center">
|
|
49
|
+
<icon class={state.icon} aria-label={state.label} tabindex="-1" />
|
|
50
|
+
</span>
|
|
51
|
+
{:else}
|
|
52
|
+
<Connector {type} />
|
|
53
|
+
{/if}
|
|
45
54
|
{/each}
|
|
55
|
+
<!-- {#each types.slice(1) as type}
|
|
56
|
+
<Connector {type} />
|
|
57
|
+
{/each} -->
|
|
46
58
|
|
|
47
|
-
{#if hasChildren}
|
|
59
|
+
<!-- {#if hasChildren}
|
|
48
60
|
<span class="flex flex-col w-4 h-full items-center justify-center">
|
|
49
61
|
<icon class={state.icon} aria-label={state.label} tabindex="-1" />
|
|
50
62
|
</span>
|
|
51
|
-
{/if}
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
{/if} -->
|
|
64
|
+
<fragment>
|
|
65
|
+
<svelte:component this={component} bind:content {fields} />
|
|
66
|
+
</fragment>
|
|
54
67
|
</node>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function getLineTypes(
|
|
2
|
+
hasChildren = false,
|
|
3
|
+
parentTypes = [],
|
|
4
|
+
position = 'middle'
|
|
5
|
+
) {
|
|
6
|
+
let types = parentTypes.slice(0, -1).map((type) => {
|
|
7
|
+
return type === 'middle' ? 'line' : type === 'last' ? 'empty' : type
|
|
8
|
+
})
|
|
9
|
+
if (parentTypes.length > 0) types.push(position)
|
|
10
|
+
types.push(hasChildren ? 'icon' : 'empty')
|
|
11
|
+
return types
|
|
12
|
+
}
|