@rokkit/core 1.0.0-next.12 → 1.0.0-next.14
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 +1 -1
- package/src/DropDown.svelte +6 -3
- package/src/EditableTabs.svelte +31 -0
- package/src/Tabs.svelte +39 -21
- package/src/actions/hierarchy.js +7 -16
- package/src/actions/navigable.js +1 -0
- package/src/items/Link.svelte +1 -0
package/package.json
CHANGED
package/src/DropDown.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import Icon from './Icon.svelte'
|
|
7
7
|
import Text from './items/Text.svelte'
|
|
8
8
|
import List from './List.svelte'
|
|
9
|
+
import Slider from './Slider.svelte'
|
|
9
10
|
|
|
10
11
|
const dispatch = createEventDispatcher()
|
|
11
12
|
|
|
@@ -62,10 +63,11 @@
|
|
|
62
63
|
{/if}
|
|
63
64
|
</button>
|
|
64
65
|
{#if open}
|
|
65
|
-
<div
|
|
66
|
+
<!-- <div
|
|
66
67
|
class="flex flex-col absolute z-10 h-fit w-full menu"
|
|
67
68
|
style:top="{offsetTop}px"
|
|
68
|
-
>
|
|
69
|
+
> -->
|
|
70
|
+
<Slider top={offsetTop}>
|
|
69
71
|
<List
|
|
70
72
|
{items}
|
|
71
73
|
{fields}
|
|
@@ -74,6 +76,7 @@
|
|
|
74
76
|
on:select={handleSelect}
|
|
75
77
|
tabindex="-1"
|
|
76
78
|
/>
|
|
77
|
-
</
|
|
79
|
+
</Slider>
|
|
80
|
+
<!-- </div> -->
|
|
78
81
|
{/if}
|
|
79
82
|
</drop-down>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import TabItems from './TabItems.svelte'
|
|
3
|
+
import TabItem from './TabItem.svelte'
|
|
4
|
+
|
|
5
|
+
let className = ''
|
|
6
|
+
export { className as class }
|
|
7
|
+
export let items = []
|
|
8
|
+
export let fields = {}
|
|
9
|
+
export let title = null
|
|
10
|
+
export let allowAdd = false
|
|
11
|
+
export let allowClose = false
|
|
12
|
+
export let value = items[0]
|
|
13
|
+
|
|
14
|
+
function addTab() {
|
|
15
|
+
items = [...items, {}]
|
|
16
|
+
value = items[items.length - 1]
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<tab-view class="flex flex-col w-full flex-grow {className}">
|
|
21
|
+
<tabs class="flex flex-row flex-shrink-0 w-full select-none cursor-pointer">
|
|
22
|
+
{#if title}
|
|
23
|
+
<p>{title}</p>
|
|
24
|
+
{/if}
|
|
25
|
+
<TabItems {items} {fields} {allowClose} bind:value on:close />
|
|
26
|
+
{#if allowAdd}
|
|
27
|
+
<TabItem label="+" on:click={addTab} />
|
|
28
|
+
{/if}
|
|
29
|
+
</tabs>
|
|
30
|
+
<content class="flex flex-col flex-grow"><slot /></content>
|
|
31
|
+
</tab-view>
|
package/src/Tabs.svelte
CHANGED
|
@@ -1,31 +1,49 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { defaultFields } from './constants'
|
|
3
|
+
import { Text } from './items'
|
|
4
|
+
import { navigator } from './actions'
|
|
5
|
+
import { createEventDispatcher } from 'svelte'
|
|
6
|
+
|
|
7
|
+
const dispatch = createEventDispatcher()
|
|
4
8
|
|
|
5
9
|
let className = ''
|
|
6
10
|
export { className as class }
|
|
7
11
|
export let items = []
|
|
8
12
|
export let fields = {}
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
export let using = {}
|
|
14
|
+
export let value = null
|
|
15
|
+
let cursor = []
|
|
16
|
+
|
|
17
|
+
function handleNav(event) {
|
|
18
|
+
value = event.detail.node
|
|
19
|
+
cursor = event.detail.path
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
items = [...items, {}]
|
|
16
|
-
value = items[items.length - 1]
|
|
21
|
+
dispatch('select', { item: value, indices: cursor })
|
|
17
22
|
}
|
|
23
|
+
$: fields = { ...defaultFields, ...fields }
|
|
24
|
+
$: using = { default: Text, ...using }
|
|
18
25
|
</script>
|
|
19
26
|
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
<tabs
|
|
28
|
+
class="flex w-full {className}"
|
|
29
|
+
tabindex="0"
|
|
30
|
+
role="listbox"
|
|
31
|
+
use:navigator={{
|
|
32
|
+
items,
|
|
33
|
+
fields,
|
|
34
|
+
vertical: false,
|
|
35
|
+
indices: cursor
|
|
36
|
+
}}
|
|
37
|
+
on:move={handleNav}
|
|
38
|
+
on:select={handleNav}
|
|
39
|
+
>
|
|
40
|
+
{#each items as item, index}
|
|
41
|
+
{@const component = item[fields.component]
|
|
42
|
+
? using[item[fields.component]] || using.default
|
|
43
|
+
: using.default}
|
|
44
|
+
|
|
45
|
+
<item class="flex" class:is-selected={item === value} data-path={index}>
|
|
46
|
+
<svelte:component this={component} content={item} {fields} />
|
|
47
|
+
</item>
|
|
48
|
+
{/each}
|
|
49
|
+
</tabs>
|
package/src/actions/hierarchy.js
CHANGED
|
@@ -135,6 +135,13 @@ export function movePrevious(path) {
|
|
|
135
135
|
return path
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @param {Array<integer>} indices
|
|
141
|
+
* @param {Array<*>} items
|
|
142
|
+
* @param {import('../constants').FieldMapping} fields
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
138
145
|
export function pathFromIndices(indices, items, fields) {
|
|
139
146
|
let path = []
|
|
140
147
|
let fragment
|
|
@@ -171,19 +178,3 @@ export function findItem(items, indices, fields) {
|
|
|
171
178
|
}
|
|
172
179
|
return item
|
|
173
180
|
}
|
|
174
|
-
|
|
175
|
-
// export function getNodeFromIndices(indices, items, fields) {
|
|
176
|
-
// let fragment
|
|
177
|
-
// indices.map((index, level) => {
|
|
178
|
-
// if (level === 0) {
|
|
179
|
-
// fragment = { index, items, fields }
|
|
180
|
-
// } else {
|
|
181
|
-
// fragment = {
|
|
182
|
-
// index,
|
|
183
|
-
// items: fragment.items[fragment.index][fragment.fields.children],
|
|
184
|
-
// fields: fragment.fields.fields ?? fragment.fields
|
|
185
|
-
// }
|
|
186
|
-
// }
|
|
187
|
-
// })
|
|
188
|
-
// return indices.length === 0 ? null : fragment.items[fragment.index]
|
|
189
|
-
// }
|
package/src/actions/navigable.js
CHANGED
|
@@ -2,6 +2,7 @@ export function navigable(
|
|
|
2
2
|
node,
|
|
3
3
|
{ horizontal = true, nested = false, enabled = true } = {}
|
|
4
4
|
) {
|
|
5
|
+
// console.log(node, enabled)
|
|
5
6
|
if (!enabled) return { destroy() {} }
|
|
6
7
|
const previous = () => node.dispatchEvent(new CustomEvent('previous'))
|
|
7
8
|
const next = () => node.dispatchEvent(new CustomEvent('next'))
|