@rokkit/core 1.0.0-next.13 → 1.0.0-next.15

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.13",
3
+ "version": "1.0.0-next.15",
4
4
  "description": "Core components, actions and stores for svelte apps.",
5
5
  "author": "Jerry Thomas <me@jerrythomas.name>",
6
6
  "license": "MIT",
@@ -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
- // }
@@ -9,7 +9,7 @@
9
9
  </script>
10
10
 
11
11
  <a
12
- class="flex flex-row flex-grow gap-2 items-center content"
12
+ class="flex flex-row flex-grow items-center"
13
13
  href={content[fields.url]}
14
14
  {target}
15
15
  tabindex="-1"
@@ -32,7 +32,7 @@
32
32
  <!-- svelte-ignore a11y-click-events-have-key-events -->
33
33
  <node
34
34
  id={'id-' + path.join('-')}
35
- class="flex flex-row h-8 gap-2 leading-loose items-center cursor-pointer select-none"
35
+ class="flex flex-row min-h-5 items-center cursor-pointer select-none"
36
36
  class:is-selected={selected}
37
37
  aria-selected={selected}
38
38
  role="option"
@@ -1,19 +1,33 @@
1
1
  <script>
2
2
  import { createEventDispatcher } from 'svelte'
3
- import { defaultStateIcons } from '../constants'
4
-
3
+ import { defaultFields, defaultStateIcons } from '../constants'
4
+ import Text from './Text.svelte'
5
5
  const dispatch = createEventDispatcher()
6
6
 
7
- export let item
8
- export let fields
7
+ export let value
8
+ export let fields = defaultFields
9
+ export let using = { default: Text }
10
+ export let removable = false
9
11
 
10
12
  function handleClick() {
11
- dispatch('remove', item)
13
+ dispatch('remove', value)
12
14
  }
15
+ $: component =
16
+ typeof value == 'object'
17
+ ? using[value[fields.component] ?? 'default']
18
+ : using.default
19
+ $: console.log(value, component)
13
20
  </script>
14
21
 
15
22
  <pill class="flex flex-row items-center">
16
- {item[fields.text]}
23
+ <item class="flex flex-row items-center">
24
+ <svelte:component this={component} content={value} {fields} />
25
+ </item>
17
26
  <!-- svelte-ignore a11y-click-events-have-key-events -->
18
- <icon class={defaultStateIcons.item.remove} on:click={handleClick} />
27
+ {#if removable}
28
+ <icon
29
+ class="{defaultStateIcons.action.remove} cursor-pointer"
30
+ on:click={handleClick}
31
+ />
32
+ {/if}
19
33
  </pill>