@rokkit/core 1.0.0-next.18 → 1.0.0-next.20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/core",
3
- "version": "1.0.0-next.18",
3
+ "version": "1.0.0-next.20",
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.2",
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=. .",
@@ -35,7 +35,7 @@
35
35
 
36
36
  <!-- svelte-ignore a11y-no-noninteractive-tabindex -->
37
37
  <drop-down
38
- class="flex w-full relative cursor-pointer select-none dropdown {className}"
38
+ class="flex relative cursor-pointer select-none dropdown {className}"
39
39
  class:open
40
40
  tabindex="0"
41
41
  aria-haspopup="true"
@@ -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
@@ -27,7 +28,7 @@
27
28
  $: using = { default: Text, ...using }
28
29
  $: fields = { ...defaultFields, ...fields }
29
30
  $: nodeTypes = items.map((_, index) =>
30
- index === items.length - 1 ? 'last' : 'middle'
31
+ index === items.length - 1 ? 'last' : 'child'
31
32
  )
32
33
  </script>
33
34
 
@@ -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 = types.slice(0, -1)}
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={[...connectors, nodeTypes[index]]}
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={[...connectors, type, nodeTypes[index]]}
72
- {linesVisible}
74
+ types={connectors}
73
75
  hierarchy={path}
74
76
  />
75
77
  {/if}
@@ -1,9 +1,11 @@
1
1
  <script>
2
- export let type
2
+ export let type = null
3
3
  export let rtl = false
4
+
5
+ $: type = ['last', 'child', 'sibling'].includes(type) ? type : 'empty'
4
6
  </script>
5
7
 
6
- <span class="grid grid-rows-2 grid-cols-2 h-full w-4">
8
+ <span class="grid grid-rows-2 grid-cols-2 h-full w-4 line-{type}">
7
9
  {#if type === 'last'}
8
10
  {#if rtl}
9
11
  <i class="border-b border-r" />
@@ -11,7 +13,7 @@
11
13
  <i class="border-r" />
12
14
  <i class="border-b" />
13
15
  {/if}
14
- {:else if type === 'middle'}
16
+ {:else if type === 'child'}
15
17
  {#if rtl}
16
18
  <i class="border-r grid grid-rows-2 row-span-2">
17
19
  <i class="border-b" />
@@ -20,7 +22,7 @@
20
22
  <i class="border-r col-span-1 row-span-2" />
21
23
  <i class="border-b" />
22
24
  {/if}
23
- {:else if type === 'line'}
25
+ {:else if type === 'sibling'}
24
26
  <i class="border-r row-span-2" />
25
27
  {/if}
26
28
  </span>
@@ -1,14 +1,16 @@
1
1
  <script>
2
2
  import Connector from './Connector.svelte'
3
3
  import { defaultFields, defaultStateIcons } from '../constants'
4
- import { createEventDispatcher } from 'svelte'
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.slice(1) as type}
44
- <Connector type={linesVisible ? type : 'empty'} />
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
- <svelte:component this={component} bind:content {fields} />
63
+ {/if} -->
64
+ <fragment>
65
+ <svelte:component this={component} bind:content {fields} />
66
+ </fragment>
54
67
  </node>
@@ -16,7 +16,6 @@
16
16
  typeof value == 'object'
17
17
  ? using[value[fields.component] ?? 'default']
18
18
  : using.default
19
- $: console.log(value, component)
20
19
  </script>
21
20
 
22
21
  <pill class="flex flex-row items-center">
@@ -0,0 +1,12 @@
1
+ export function getLineTypes(
2
+ hasChildren = false,
3
+ parentTypes = [],
4
+ position = 'child'
5
+ ) {
6
+ let types = parentTypes.slice(0, -1).map((type) => {
7
+ return type === 'child' ? 'sibling' : type === 'last' ? 'empty' : type
8
+ })
9
+ if (parentTypes.length > 0) types.push(position)
10
+ types.push(hasChildren ? 'icon' : 'empty')
11
+ return types
12
+ }