@rokkit/core 1.0.0-next.32 → 1.0.0-next.34
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 +13 -11
- package/src/ListActions.svelte +1 -1
- package/src/NestedPaginator.svelte +3 -4
- package/src/PageNavigator.svelte +2 -2
- package/src/ResponsiveGrid.svelte +1 -2
- package/src/SpinList.svelte +5 -5
- package/src/SplitPane.svelte +1 -1
- package/src/Splitter.svelte +1 -1
- package/src/TabItems.svelte +1 -1
- package/src/index.js +15 -15
- package/src/Accordion.svelte +0 -80
- package/src/Alerts.svelte +0 -39
- package/src/BreadCrumbs.svelte +0 -34
- package/src/DropDown.svelte +0 -82
- package/src/DropSearch.svelte +0 -67
- package/src/Icon.svelte +0 -38
- package/src/List.svelte +0 -66
- package/src/NestedList.svelte +0 -59
- package/src/Slider.svelte +0 -17
- package/src/Switch.svelte +0 -69
- package/src/Tabs.svelte +0 -82
- package/src/Tree.svelte +0 -52
- package/src/actions/dismissable.js +0 -24
- package/src/actions/fillable.js +0 -114
- package/src/actions/hierarchy.js +0 -180
- package/src/actions/index.js +0 -7
- package/src/actions/navigable.js +0 -42
- package/src/actions/navigator.js +0 -179
- package/src/actions/pannable.js +0 -57
- package/src/actions/swipeable.js +0 -55
- package/src/actions/themeable.js +0 -23
- package/src/constants.js +0 -95
- package/src/items/Connector.svelte +0 -28
- package/src/items/Item.svelte +0 -29
- package/src/items/ItemWrapper.svelte +0 -47
- package/src/items/Link.svelte +0 -18
- package/src/items/Node.svelte +0 -47
- package/src/items/Separator.svelte +0 -1
- package/src/items/Summary.svelte +0 -27
- package/src/items/index.js +0 -7
- package/src/lib/connector.js +0 -12
- package/src/lib/index.js +0 -7
- package/src/lib/nested.js +0 -45
- package/src/list.js +0 -14
- package/src/mocks/Custom.svelte +0 -6
- package/src/mocks/index.js +0 -17
- package/src/stores/alerts.js +0 -2
- package/src/stores/index.js +0 -6
- package/src/stores/persist.js +0 -63
- package/src/stores/theme.js +0 -34
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.34",
|
|
4
4
|
"description": "Core components, actions and stores for svelte apps.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@sveltejs/vite-plugin-svelte": "^2.4.
|
|
17
|
-
"@testing-library/svelte": "^
|
|
18
|
-
"@vitest/coverage-c8": "^0.
|
|
19
|
-
"@vitest/coverage-istanbul": "^0.
|
|
20
|
-
"@vitest/ui": "~0.
|
|
16
|
+
"@sveltejs/vite-plugin-svelte": "^2.4.2",
|
|
17
|
+
"@testing-library/svelte": "^4.0.3",
|
|
18
|
+
"@vitest/coverage-c8": "^0.32.3",
|
|
19
|
+
"@vitest/coverage-istanbul": "^0.32.3",
|
|
20
|
+
"@vitest/ui": "~0.32.3",
|
|
21
21
|
"jsdom": "^22.1.0",
|
|
22
|
-
"svelte": "^
|
|
23
|
-
"typescript": "^5.
|
|
22
|
+
"svelte": "^4.0.1",
|
|
23
|
+
"typescript": "^5.1.6",
|
|
24
24
|
"validators": "latest",
|
|
25
25
|
"vite": "^4.3.9",
|
|
26
|
-
"vitest": "~0.
|
|
27
|
-
"shared-config": "1.0.0-next.
|
|
26
|
+
"vitest": "~0.32.3",
|
|
27
|
+
"shared-config": "1.0.0-next.34"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"src/**/*.js",
|
|
@@ -44,7 +44,9 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"
|
|
47
|
+
"@rokkit/molecules": "1.0.0-next.33",
|
|
48
|
+
"ramda": "^0.29.0",
|
|
49
|
+
"rokkit": "1.0.0-next.33"
|
|
48
50
|
},
|
|
49
51
|
"scripts": {
|
|
50
52
|
"format": "prettier --write .",
|
package/src/ListActions.svelte
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { flattenNestedList } from './lib/nested'
|
|
2
|
+
import { defaultFields, flattenNestedList } from 'rokkit/utils'
|
|
3
|
+
import { Item, BreadCrumbs } from '@rokkit/molecules'
|
|
4
|
+
// import { flattenNestedList } from './lib/nested'
|
|
6
5
|
import { createEventDispatcher } from 'svelte'
|
|
7
6
|
|
|
8
7
|
const dispatch = createEventDispatcher()
|
package/src/PageNavigator.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { defaultFields, defaultStateIcons } from '
|
|
4
|
-
import Icon from '
|
|
3
|
+
import { defaultFields, defaultStateIcons } from 'rokkit/utils'
|
|
4
|
+
import { Icon } from 'rokkit/atoms'
|
|
5
5
|
|
|
6
6
|
const dispatch = createEventDispatcher()
|
|
7
7
|
|
package/src/SpinList.svelte
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { defaultFields } from '
|
|
4
|
-
import { Item } from '
|
|
5
|
-
import { navigable } from '
|
|
6
|
-
import { getComponent } from './list'
|
|
3
|
+
import { defaultFields } from 'rokkit/utils'
|
|
4
|
+
import { Item } from '@rokkit/molecules'
|
|
5
|
+
import { navigable } from 'rokkit/actions'
|
|
6
|
+
// import { getComponent } from './list'
|
|
7
7
|
|
|
8
8
|
const dispatch = createEventDispatcher()
|
|
9
9
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
$: using = { default: Item, ...using }
|
|
28
28
|
$: fields = { ...defaultFields, ...fields }
|
|
29
29
|
$: value = index >= 0 ? items[index] : null
|
|
30
|
-
$: component = getComponent(value, fields)
|
|
30
|
+
// $: component = getComponent(value, fields)
|
|
31
31
|
</script>
|
|
32
32
|
|
|
33
33
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
package/src/SplitPane.svelte
CHANGED
package/src/Splitter.svelte
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// ensure that parent has position: relative.
|
|
3
3
|
// on reaching limit remove mouse events.
|
|
4
4
|
import { createEventDispatcher } from 'svelte'
|
|
5
|
-
import { pannable } from '
|
|
5
|
+
import { pannable } from 'rokkit/actions'
|
|
6
6
|
|
|
7
7
|
const dispatch = createEventDispatcher()
|
|
8
8
|
|
package/src/TabItems.svelte
CHANGED
package/src/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export * from './constants'
|
|
2
|
-
export * from './items'
|
|
3
|
-
export * from './lib'
|
|
1
|
+
// export * from './constants'
|
|
2
|
+
// export * from './items'
|
|
3
|
+
// export * from './lib'
|
|
4
4
|
|
|
5
|
-
export { default as Icon } from './Icon.svelte'
|
|
6
|
-
export { default as Switch } from './Switch.svelte'
|
|
7
|
-
export { default as Tree } from './Tree.svelte'
|
|
8
|
-
export { default as Accordion } from './Accordion.svelte'
|
|
9
|
-
export { default as List } from './List.svelte'
|
|
5
|
+
// export { default as Icon } from './Icon.svelte'
|
|
6
|
+
// export { default as Switch } from './Switch.svelte'
|
|
7
|
+
// export { default as Tree } from './Tree.svelte'
|
|
8
|
+
// export { default as Accordion } from './Accordion.svelte'
|
|
9
|
+
// export { default as List } from './List.svelte'
|
|
10
10
|
export { default as Searchable } from './Searchable.svelte'
|
|
11
11
|
export { default as Scrollable } from './Scrollable.svelte'
|
|
12
|
-
export { default as NestedList } from './NestedList.svelte'
|
|
13
|
-
export { default as Tabs } from './Tabs.svelte'
|
|
14
|
-
export { default as BreadCrumbs } from './BreadCrumbs.svelte'
|
|
12
|
+
// export { default as NestedList } from './NestedList.svelte'
|
|
13
|
+
// export { default as Tabs } from './Tabs.svelte'
|
|
14
|
+
// export { default as BreadCrumbs } from './BreadCrumbs.svelte'
|
|
15
15
|
export { default as NestedPaginator } from './NestedPaginator.svelte'
|
|
16
16
|
|
|
17
|
-
export { default as Alerts } from './Alerts.svelte'
|
|
18
|
-
export { default as Slider } from './Slider.svelte'
|
|
19
|
-
export { default as DropDown } from './DropDown.svelte'
|
|
20
|
-
export { default as DropSearch } from './DropSearch.svelte'
|
|
17
|
+
// export { default as Alerts } from './Alerts.svelte'
|
|
18
|
+
// export { default as Slider } from './Slider.svelte'
|
|
19
|
+
// export { default as DropDown } from './DropDown.svelte'
|
|
20
|
+
// export { default as DropSearch } from './DropSearch.svelte'
|
|
21
21
|
export { default as SpinList } from './SpinList.svelte'
|
|
22
22
|
|
|
23
23
|
export { default as Sidebar } from './Sidebar.svelte'
|
package/src/Accordion.svelte
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { defaultFields } from './constants'
|
|
4
|
-
import { Item, Summary } from './items'
|
|
5
|
-
import List from './List.svelte'
|
|
6
|
-
import { navigator } from './actions/navigator'
|
|
7
|
-
|
|
8
|
-
const dispatch = createEventDispatcher()
|
|
9
|
-
let className = ''
|
|
10
|
-
export { className as class }
|
|
11
|
-
export let items = []
|
|
12
|
-
export let fields = {}
|
|
13
|
-
export let using = {}
|
|
14
|
-
export let autoClose = false
|
|
15
|
-
export let value = null
|
|
16
|
-
let cursor = []
|
|
17
|
-
|
|
18
|
-
$: fields = { ...defaultFields, ...fields }
|
|
19
|
-
$: using = { default: Item, ...using }
|
|
20
|
-
|
|
21
|
-
function handle(event) {
|
|
22
|
-
// console.log(event.type, event.detail)
|
|
23
|
-
value = event.detail.node
|
|
24
|
-
cursor = event.detail.path
|
|
25
|
-
if (['collapse', 'expand'].includes(event.type)) {
|
|
26
|
-
if (autoClose) {
|
|
27
|
-
items.map((x) => {
|
|
28
|
-
if (x !== value && x[fields.isOpen]) {
|
|
29
|
-
x[fields.isOpen] = false
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
items = items
|
|
34
|
-
}
|
|
35
|
-
dispatch(event.type, event.detail)
|
|
36
|
-
}
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
40
|
-
<accordion
|
|
41
|
-
class="flex flex-col w-full select-none {className}"
|
|
42
|
-
tabindex="0"
|
|
43
|
-
use:navigator={{
|
|
44
|
-
items,
|
|
45
|
-
fields,
|
|
46
|
-
enabled: true,
|
|
47
|
-
indices: cursor
|
|
48
|
-
}}
|
|
49
|
-
on:select={handle}
|
|
50
|
-
on:move={handle}
|
|
51
|
-
on:expand={handle}
|
|
52
|
-
on:collapse={handle}
|
|
53
|
-
>
|
|
54
|
-
{#each items as item, index}
|
|
55
|
-
{@const hasItems =
|
|
56
|
-
item[fields.children] && item[fields.children].length > 0}
|
|
57
|
-
{@const itemFields = { ...fields, ...(fields.fields ?? fields) }}
|
|
58
|
-
|
|
59
|
-
<div
|
|
60
|
-
id={'id-' + index}
|
|
61
|
-
class="flex flex-col"
|
|
62
|
-
class:is-expanded={item[fields.isOpen]}
|
|
63
|
-
class:is-selected={item === value}
|
|
64
|
-
data-path={index}
|
|
65
|
-
>
|
|
66
|
-
<Summary {fields} {using} bind:value={item} />
|
|
67
|
-
{#if hasItems && item[fields.isOpen]}
|
|
68
|
-
<List
|
|
69
|
-
bind:items={item[fields.children]}
|
|
70
|
-
bind:value
|
|
71
|
-
fields={itemFields}
|
|
72
|
-
{using}
|
|
73
|
-
on:select
|
|
74
|
-
hierarchy={[index]}
|
|
75
|
-
tabindex="-1"
|
|
76
|
-
/>
|
|
77
|
-
{/if}
|
|
78
|
-
</div>
|
|
79
|
-
{/each}
|
|
80
|
-
</accordion>
|
package/src/Alerts.svelte
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { fade } from 'svelte/transition'
|
|
3
|
-
import { flip } from 'svelte/animate'
|
|
4
|
-
import { alerts } from './stores'
|
|
5
|
-
import { dismissable } from './actions'
|
|
6
|
-
|
|
7
|
-
function dismissAll() {
|
|
8
|
-
unreadAlerts.map((alert) => (alert.dismissed = true))
|
|
9
|
-
alerts.set([...$alerts])
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function dismiss(alert) {
|
|
13
|
-
alert.dismissed = true
|
|
14
|
-
alerts.set([...$alerts])
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
$: unreadAlerts = $alerts.filter((x) => x.dismissed)
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
{#if unreadAlerts.length > 0}
|
|
21
|
-
<alert-list
|
|
22
|
-
class="absolute z-10 flex flex-col gap-2"
|
|
23
|
-
use:dismissable
|
|
24
|
-
on:dismiss={dismissAll}
|
|
25
|
-
>
|
|
26
|
-
{#each unreadAlerts as alert (alert.id)}
|
|
27
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
28
|
-
<alert
|
|
29
|
-
class={alert.type}
|
|
30
|
-
on:click|stopPropagation={dismiss(alert)}
|
|
31
|
-
animate:flip
|
|
32
|
-
in:fade
|
|
33
|
-
out:fade
|
|
34
|
-
>
|
|
35
|
-
{alert.message}
|
|
36
|
-
</alert>
|
|
37
|
-
{/each}
|
|
38
|
-
</alert-list>
|
|
39
|
-
{/if}
|
package/src/BreadCrumbs.svelte
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { defaultFields } from './constants'
|
|
3
|
-
import { Item } from './items'
|
|
4
|
-
|
|
5
|
-
export let items = []
|
|
6
|
-
export let separator = '/'
|
|
7
|
-
export let fields = defaultFields
|
|
8
|
-
export let using
|
|
9
|
-
|
|
10
|
-
$: fields = { ...defaultFields, ...(fields ?? {}) }
|
|
11
|
-
$: using = { default: Item, ...(using ?? {}) }
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<crumbs class="flex">
|
|
15
|
-
{#each items as item, index}
|
|
16
|
-
{#if item}
|
|
17
|
-
{@const component = item[fields.component]
|
|
18
|
-
? using[item[fields.component]] || using.default
|
|
19
|
-
: using.default}
|
|
20
|
-
{#if index > 0}
|
|
21
|
-
<span>
|
|
22
|
-
{#if separator.length == 1}
|
|
23
|
-
{separator}
|
|
24
|
-
{:else}
|
|
25
|
-
<icon class={separator} />
|
|
26
|
-
{/if}
|
|
27
|
-
</span>
|
|
28
|
-
{/if}
|
|
29
|
-
<crumb class:is-selected={index == items.length - 1}>
|
|
30
|
-
<svelte:component this={component} value={item} {fields} />
|
|
31
|
-
</crumb>
|
|
32
|
-
{/if}
|
|
33
|
-
{/each}
|
|
34
|
-
</crumbs>
|
package/src/DropDown.svelte
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { dismissable } from './actions'
|
|
4
|
-
import { defaultFields, defaultStateIcons } from './constants.js'
|
|
5
|
-
|
|
6
|
-
import Icon from './Icon.svelte'
|
|
7
|
-
import Item from './items/Item.svelte'
|
|
8
|
-
import List from './List.svelte'
|
|
9
|
-
import Slider from './Slider.svelte'
|
|
10
|
-
|
|
11
|
-
const dispatch = createEventDispatcher()
|
|
12
|
-
|
|
13
|
-
let className = ''
|
|
14
|
-
export { className as class }
|
|
15
|
-
export let items = []
|
|
16
|
-
export let fields = defaultFields
|
|
17
|
-
export let using = { default: Item }
|
|
18
|
-
export let value = null
|
|
19
|
-
export let title = null
|
|
20
|
-
export let icon = null
|
|
21
|
-
export let small = false
|
|
22
|
-
|
|
23
|
-
$: using = { default: Item, ...using }
|
|
24
|
-
$: fields = { ...defaultFields, ...fields }
|
|
25
|
-
|
|
26
|
-
let offsetTop = 0
|
|
27
|
-
let open = false
|
|
28
|
-
let icons = defaultStateIcons.selector
|
|
29
|
-
|
|
30
|
-
function handleSelect(event) {
|
|
31
|
-
open = false
|
|
32
|
-
dispatch('change', event.detail)
|
|
33
|
-
}
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
37
|
-
<drop-down
|
|
38
|
-
class="flex relative cursor-pointer select-none dropdown {className}"
|
|
39
|
-
class:open
|
|
40
|
-
tabindex="0"
|
|
41
|
-
aria-haspopup="true"
|
|
42
|
-
aria-controls="menu"
|
|
43
|
-
use:dismissable
|
|
44
|
-
on:blur={() => (open = false)}
|
|
45
|
-
on:dismiss={() => (open = false)}
|
|
46
|
-
>
|
|
47
|
-
<button
|
|
48
|
-
on:click|stopPropagation={() => (open = !open)}
|
|
49
|
-
class="flex items-center"
|
|
50
|
-
bind:clientHeight={offsetTop}
|
|
51
|
-
tabindex="-1"
|
|
52
|
-
>
|
|
53
|
-
{#if icon}
|
|
54
|
-
<Icon name={icon} />
|
|
55
|
-
{/if}
|
|
56
|
-
{#if !small && title}
|
|
57
|
-
<p class="w-full flex">{title}</p>
|
|
58
|
-
{/if}
|
|
59
|
-
{#if open}
|
|
60
|
-
<icon class={icons.opened} />
|
|
61
|
-
{:else}
|
|
62
|
-
<icon class={icons.closed} />
|
|
63
|
-
{/if}
|
|
64
|
-
</button>
|
|
65
|
-
{#if open}
|
|
66
|
-
<!-- <div
|
|
67
|
-
class="absolute z-10 menu h-fit w-full flex flex-col"
|
|
68
|
-
style:top="{offsetTop}px"
|
|
69
|
-
> -->
|
|
70
|
-
<Slider top={offsetTop}>
|
|
71
|
-
<List
|
|
72
|
-
{items}
|
|
73
|
-
{fields}
|
|
74
|
-
{using}
|
|
75
|
-
bind:value
|
|
76
|
-
on:select={handleSelect}
|
|
77
|
-
tabindex="-1"
|
|
78
|
-
/>
|
|
79
|
-
</Slider>
|
|
80
|
-
<!-- </div> -->
|
|
81
|
-
{/if}
|
|
82
|
-
</drop-down>
|
package/src/DropSearch.svelte
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { defaultFields } from './constants.js'
|
|
3
|
-
import List from './List.svelte'
|
|
4
|
-
import Slider from './Slider.svelte'
|
|
5
|
-
import { Item } from './items'
|
|
6
|
-
|
|
7
|
-
export let data
|
|
8
|
-
export let value = null
|
|
9
|
-
export let fields = defaultFields
|
|
10
|
-
export let using = { default: Item }
|
|
11
|
-
|
|
12
|
-
$: using = { default: Item, ...using }
|
|
13
|
-
$: fields = { ...defaultFields, ...fields }
|
|
14
|
-
|
|
15
|
-
let opened = false
|
|
16
|
-
let search
|
|
17
|
-
let searchBox
|
|
18
|
-
|
|
19
|
-
// on search change filter list
|
|
20
|
-
function handleSelect(event) {
|
|
21
|
-
console.log('selected', event)
|
|
22
|
-
value = event.detail
|
|
23
|
-
search = event.detail[fields.text]
|
|
24
|
-
}
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
28
|
-
<div
|
|
29
|
-
class="dropdown relative h-12 w-full flex flex-col outline-none"
|
|
30
|
-
tabindex={0}
|
|
31
|
-
>
|
|
32
|
-
<div class="selected-item h-12 flex flex-shrink-0 items-center pl-4">
|
|
33
|
-
<span class="flex flex-grow">
|
|
34
|
-
<input
|
|
35
|
-
type="text"
|
|
36
|
-
class="w-full border-none bg-transparent p-0"
|
|
37
|
-
bind:value={search}
|
|
38
|
-
bind:this={searchBox}
|
|
39
|
-
on:focus={() => {
|
|
40
|
-
opened = true
|
|
41
|
-
searchBox.select()
|
|
42
|
-
}}
|
|
43
|
-
on:blur={() => {
|
|
44
|
-
opened = false
|
|
45
|
-
}}
|
|
46
|
-
/>
|
|
47
|
-
</span>
|
|
48
|
-
{#if opened}
|
|
49
|
-
<icon class="selector-opened" />
|
|
50
|
-
{:else}
|
|
51
|
-
<icon class="selector-closed" />
|
|
52
|
-
{/if}
|
|
53
|
-
</div>
|
|
54
|
-
|
|
55
|
-
{#if opened}
|
|
56
|
-
<Slider>
|
|
57
|
-
<List
|
|
58
|
-
bind:items={data}
|
|
59
|
-
bind:value
|
|
60
|
-
{fields}
|
|
61
|
-
{using}
|
|
62
|
-
on:select={handleSelect}
|
|
63
|
-
on:change
|
|
64
|
-
/>
|
|
65
|
-
</Slider>
|
|
66
|
-
{/if}
|
|
67
|
-
</div>
|
package/src/Icon.svelte
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
let className = ''
|
|
3
|
-
export { className as class }
|
|
4
|
-
export let name
|
|
5
|
-
export let size = 'base'
|
|
6
|
-
export let role = 'img'
|
|
7
|
-
export let label = name
|
|
8
|
-
export let disabled = false
|
|
9
|
-
export let tabindex = 0
|
|
10
|
-
export let checked = null
|
|
11
|
-
|
|
12
|
-
$: tabindex = role === 'img' || disabled ? -1 : tabindex
|
|
13
|
-
$: small = size === 'small' || className.includes('small')
|
|
14
|
-
$: medium = size === 'medium' || className.includes('medium')
|
|
15
|
-
$: large = size === 'large' || className.includes('large')
|
|
16
|
-
$: checked = role !== 'checkbox' ? null : checked
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
20
|
-
<icon
|
|
21
|
-
class="flex flex-shrink-0 items-center justify-center {className}"
|
|
22
|
-
class:small
|
|
23
|
-
class:medium
|
|
24
|
-
class:large
|
|
25
|
-
class:disabled
|
|
26
|
-
{role}
|
|
27
|
-
aria-label={label}
|
|
28
|
-
aria-checked={checked}
|
|
29
|
-
on:mouseenter
|
|
30
|
-
on:mouseleave
|
|
31
|
-
on:focus
|
|
32
|
-
on:blur
|
|
33
|
-
on:click
|
|
34
|
-
on:keydown={(e) => e.key === 'Enter' && e.currentTarget.click()}
|
|
35
|
-
{tabindex}
|
|
36
|
-
>
|
|
37
|
-
<i class={name} aria-hidden="true" />
|
|
38
|
-
</icon>
|
package/src/List.svelte
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { navigator } from './actions'
|
|
3
|
-
import { createEventDispatcher } from 'svelte'
|
|
4
|
-
import { defaultFields } from './constants'
|
|
5
|
-
import { Item } from './items'
|
|
6
|
-
|
|
7
|
-
const dispatch = createEventDispatcher()
|
|
8
|
-
|
|
9
|
-
let className = 'list'
|
|
10
|
-
export { className as class }
|
|
11
|
-
export let items = []
|
|
12
|
-
export let fields = {}
|
|
13
|
-
export let using = {}
|
|
14
|
-
export let value = null
|
|
15
|
-
export let tabindex = 0
|
|
16
|
-
export let hierarchy = []
|
|
17
|
-
let cursor = []
|
|
18
|
-
|
|
19
|
-
function handleNav(event) {
|
|
20
|
-
value = event.detail.node
|
|
21
|
-
cursor = event.detail.path
|
|
22
|
-
|
|
23
|
-
dispatch('select', { item: value, indices: cursor })
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
$: fields = { ...defaultFields, ...fields }
|
|
27
|
-
$: using = { default: Item, ...using }
|
|
28
|
-
$: filtered = items.filter((item) => !item[fields.isDeleted])
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<list
|
|
32
|
-
class="flex flex-col w-full flex-shrink-0 select-none {className}"
|
|
33
|
-
role="listbox"
|
|
34
|
-
use:navigator={{
|
|
35
|
-
items,
|
|
36
|
-
fields,
|
|
37
|
-
enabled: hierarchy.length == 0,
|
|
38
|
-
indices: cursor
|
|
39
|
-
}}
|
|
40
|
-
on:move={handleNav}
|
|
41
|
-
on:select={handleNav}
|
|
42
|
-
{tabindex}
|
|
43
|
-
>
|
|
44
|
-
<slot />
|
|
45
|
-
{#each filtered as item, index}
|
|
46
|
-
{@const component = item[fields.component]
|
|
47
|
-
? using[item[fields.component]] || using.default
|
|
48
|
-
: using.default}
|
|
49
|
-
{@const path = [...hierarchy, index].join(',')}
|
|
50
|
-
{@const props = item[fields.props] || { fields }}
|
|
51
|
-
<item
|
|
52
|
-
class="item w-full flex flex-shrink-0 flex-grow-0 cursor-pointer select-none items-center gap-2"
|
|
53
|
-
role="option"
|
|
54
|
-
aria-selected={value === item}
|
|
55
|
-
class:is-selected={value === item}
|
|
56
|
-
data-path={path}
|
|
57
|
-
>
|
|
58
|
-
<svelte:component
|
|
59
|
-
this={component}
|
|
60
|
-
bind:value={item}
|
|
61
|
-
{...props}
|
|
62
|
-
on:change
|
|
63
|
-
/>
|
|
64
|
-
</item>
|
|
65
|
-
{/each}
|
|
66
|
-
</list>
|
package/src/NestedList.svelte
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { Node, Item } from './items'
|
|
3
|
-
import { defaultFields, defaultStateIcons } from './constants'
|
|
4
|
-
import { getLineTypes } from './lib/connector'
|
|
5
|
-
|
|
6
|
-
let className = 'list'
|
|
7
|
-
export { className as class }
|
|
8
|
-
export let items = []
|
|
9
|
-
export let fields = defaultFields
|
|
10
|
-
export let using = {}
|
|
11
|
-
export let types = []
|
|
12
|
-
export let value = null
|
|
13
|
-
export let rtl = false
|
|
14
|
-
export let hierarchy = []
|
|
15
|
-
export let icons
|
|
16
|
-
|
|
17
|
-
$: using = { default: Item, ...using }
|
|
18
|
-
$: fields = { ...defaultFields, ...fields }
|
|
19
|
-
$: nodeTypes = items.map((_, index) =>
|
|
20
|
-
index === items.length - 1 ? 'last' : 'child'
|
|
21
|
-
)
|
|
22
|
-
$: icons = { ...defaultStateIcons.node, ...icons }
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<nested-list
|
|
26
|
-
class="flex flex-col w-full {className}"
|
|
27
|
-
role="listbox"
|
|
28
|
-
class:rtl
|
|
29
|
-
tabindex="-1"
|
|
30
|
-
>
|
|
31
|
-
{#each items as item, index}
|
|
32
|
-
{@const hasChildren = fields.children in item}
|
|
33
|
-
{@const path = [...hierarchy, index]}
|
|
34
|
-
{@const connectors = getLineTypes(hasChildren, types, nodeTypes[index])}
|
|
35
|
-
|
|
36
|
-
<Node
|
|
37
|
-
bind:value={item}
|
|
38
|
-
{fields}
|
|
39
|
-
{using}
|
|
40
|
-
types={connectors}
|
|
41
|
-
{rtl}
|
|
42
|
-
{path}
|
|
43
|
-
stateIcons={icons}
|
|
44
|
-
selected={value === item}
|
|
45
|
-
/>
|
|
46
|
-
<!-- types={[...connectors, type, nodeTypes[index]]} -->
|
|
47
|
-
{#if hasChildren && item[fields.isOpen]}
|
|
48
|
-
<svelte:self
|
|
49
|
-
items={item[fields.children]}
|
|
50
|
-
bind:value
|
|
51
|
-
{fields}
|
|
52
|
-
{using}
|
|
53
|
-
{icons}
|
|
54
|
-
types={connectors}
|
|
55
|
-
hierarchy={path}
|
|
56
|
-
/>
|
|
57
|
-
{/if}
|
|
58
|
-
{/each}
|
|
59
|
-
</nested-list>
|
package/src/Slider.svelte
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { slide, fade } from 'svelte/transition'
|
|
3
|
-
|
|
4
|
-
let className = 'menu'
|
|
5
|
-
export { className as class }
|
|
6
|
-
export let top
|
|
7
|
-
export let offset = -top
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<scroll
|
|
11
|
-
in:slide={{ duration: 50, y: offset }}
|
|
12
|
-
out:fade={{ duration: 50 }}
|
|
13
|
-
style:top="{top}px"
|
|
14
|
-
class="flex flex-col absolute w-full z-10 overflow-scroll {className}"
|
|
15
|
-
>
|
|
16
|
-
<slot />
|
|
17
|
-
</scroll>
|