@rokkit/ui 1.0.0-next.111 → 1.0.0-next.112
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/dist/index.d.ts +1 -0
- package/package.json +5 -4
- package/src/Button.svelte +61 -0
- package/src/Icon.svelte +1 -0
- package/src/Node.svelte +7 -7
- package/src/Switch.svelte +12 -8
- package/src/index.js +1 -0
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/ui",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.112",
|
|
4
4
|
"description": "Organisms are larger, more complex building blocks that are composed of multiple molecules",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"prepublishOnly": "tsc --project tsconfig.build.json",
|
|
13
|
+
"prepublishOnly": "bunx tsc --project tsconfig.build.json",
|
|
14
14
|
"clean": "rm -rf dist",
|
|
15
15
|
"build": "bun clean && bun prepublishOnly"
|
|
16
16
|
},
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@rokkit/actions": "latest",
|
|
34
34
|
"@rokkit/core": "latest",
|
|
35
|
-
"@rokkit/states": "latest",
|
|
36
35
|
"@rokkit/data": "latest",
|
|
37
36
|
"@rokkit/input": "latest",
|
|
37
|
+
"@rokkit/states": "latest",
|
|
38
38
|
"d3-scale": "^4.0.2",
|
|
39
39
|
"date-fns": "^4.1.0",
|
|
40
|
-
"ramda": "^0.30.1"
|
|
40
|
+
"ramda": "^0.30.1",
|
|
41
|
+
"typescript": "^5.8.3"
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} ButtonProps
|
|
4
|
+
* @property {'default' | 'primary' | 'secondary' | 'tertiary'} variant - The variant of the button.
|
|
5
|
+
* @property {'button' | 'submit' | 'reset'} type - The type of the button.
|
|
6
|
+
* @property {string} [label] - The label of the button.
|
|
7
|
+
* @property {string|import('svelte').Snippet} [leftIcon] - The left icon of the button.
|
|
8
|
+
* @property {string|import('svelte').Snippet} [rightIcon] - The right icon of the button.
|
|
9
|
+
* @property {import('svelte').Snippet} [children]
|
|
10
|
+
* @property {Function} onclick - The onclick event of the button.
|
|
11
|
+
* @property {Function} onsubmit - The onsubmit event of the button.
|
|
12
|
+
* @property {Function} onreset - The onreset event of the button.
|
|
13
|
+
*/
|
|
14
|
+
/** @type {ButtonProps} */
|
|
15
|
+
let {
|
|
16
|
+
variant = 'default',
|
|
17
|
+
type = 'button',
|
|
18
|
+
leftIcon = null,
|
|
19
|
+
rightIcon = null,
|
|
20
|
+
label = null,
|
|
21
|
+
children = null,
|
|
22
|
+
description = null,
|
|
23
|
+
onclick,
|
|
24
|
+
onsubmit,
|
|
25
|
+
onreset
|
|
26
|
+
} = $props()
|
|
27
|
+
|
|
28
|
+
const primary = $derived(variant === 'primary')
|
|
29
|
+
const secondary = $derived(variant === 'secondary')
|
|
30
|
+
const tertiary = $derived(variant === 'tertiary')
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<button
|
|
34
|
+
class:primary
|
|
35
|
+
class:secondary
|
|
36
|
+
class:tertiary
|
|
37
|
+
class={classes}
|
|
38
|
+
{type}
|
|
39
|
+
{onclick}
|
|
40
|
+
{onsubmit}
|
|
41
|
+
{onreset}
|
|
42
|
+
aria-label={description ?? label}
|
|
43
|
+
>
|
|
44
|
+
{#if typeof leftIcon === 'string'}
|
|
45
|
+
<Icon name={leftIcon} />
|
|
46
|
+
{:else}
|
|
47
|
+
{@render leftIcon?.()}
|
|
48
|
+
{/if}
|
|
49
|
+
|
|
50
|
+
{#if children}
|
|
51
|
+
{@render children()}
|
|
52
|
+
{:else if label}
|
|
53
|
+
{label}
|
|
54
|
+
{/if}
|
|
55
|
+
|
|
56
|
+
{#if typeof rightIcon === 'string'}
|
|
57
|
+
<Icon name={rightIcon} />
|
|
58
|
+
{:else}
|
|
59
|
+
{@render rightIcon?.()}
|
|
60
|
+
{/if}
|
|
61
|
+
</button>
|
package/src/Icon.svelte
CHANGED
package/src/Node.svelte
CHANGED
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
{/each}
|
|
62
62
|
<rk-item>
|
|
63
63
|
<svelte:boundary>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
{#if template}
|
|
65
|
+
{@render template(value)}
|
|
66
|
+
{#snippet failed()}
|
|
67
|
+
<Item {value} {fields} />
|
|
68
|
+
{/snippet}
|
|
69
|
+
{:else}
|
|
67
70
|
<Item {value} {fields} />
|
|
68
|
-
{/
|
|
69
|
-
<!-- {:else}
|
|
70
|
-
<Item {value} {fields} />
|
|
71
|
-
{/if} -->
|
|
71
|
+
{/if}
|
|
72
72
|
</svelte:boundary>
|
|
73
73
|
</rk-item>
|
|
74
74
|
</div>
|
package/src/Switch.svelte
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { equals } from 'ramda'
|
|
3
|
-
import { noop,
|
|
3
|
+
import { noop, FieldMapper } from '@rokkit/core'
|
|
4
4
|
import { keyboard } from '@rokkit/actions'
|
|
5
|
-
import
|
|
5
|
+
import Item from './Item.svelte'
|
|
6
|
+
// import { defaultMapping } from './constants'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @typedef {Object} Props
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
...extra
|
|
28
29
|
} = $props()
|
|
29
30
|
|
|
30
|
-
let cursor = $state([])
|
|
31
|
+
// let cursor = $state([])
|
|
31
32
|
|
|
32
33
|
function toggle(direction = 1) {
|
|
33
34
|
let nextIndex
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
next: ['ArrowRight', 'ArrowDown', ' ', 'Enter'],
|
|
52
53
|
prev: ['ArrowLeft', 'ArrowUp']
|
|
53
54
|
}
|
|
54
|
-
let useComponent = $derived(!options.every((item) => [false, true].includes(item)))
|
|
55
|
-
let mapper = new FieldMapper(fields)
|
|
55
|
+
// let useComponent = $derived(!options.every((item) => [false, true].includes(item)))
|
|
56
|
+
// let mapper = new FieldMapper(fields)
|
|
56
57
|
</script>
|
|
57
58
|
|
|
58
59
|
{#if !Array.isArray(options) || options.length < 2}
|
|
@@ -75,13 +76,16 @@
|
|
|
75
76
|
onclick={handleClick}
|
|
76
77
|
>
|
|
77
78
|
{#each options as item, index (item)}
|
|
78
|
-
{@const Template = getSnippet(extra, mapper.get('snippet', item), stub)}
|
|
79
|
+
<!-- {@const Template = getSnippet(extra, mapper.get('snippet', item), stub)} -->
|
|
79
80
|
<rk-item class="relative" role="option" aria-selected={equals(item, value)} data-path={index}>
|
|
80
81
|
{#if equals(item, value)}
|
|
81
82
|
<rk-indicator class="absolute bottom-0 left-0 right-0 top-0"></rk-indicator>
|
|
82
83
|
{/if}
|
|
83
|
-
{#if
|
|
84
|
-
|
|
84
|
+
{#if stub}
|
|
85
|
+
{@render stub(item, fields)}
|
|
86
|
+
<!-- <Template value={item} {fields} /> -->
|
|
87
|
+
{:else}
|
|
88
|
+
<Item value={item} {fields} />
|
|
85
89
|
{/if}
|
|
86
90
|
</rk-item>
|
|
87
91
|
{/each}
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// skipcq: JS-E1004 - Needed for exposing JS Doc types
|
|
2
2
|
export * from './types.js'
|
|
3
|
+
export { default as Button } from './Button.svelte'
|
|
3
4
|
export { default as Icon } from './Icon.svelte'
|
|
4
5
|
export { default as Item } from './Item.svelte'
|
|
5
6
|
export { default as Pill } from './Pill.svelte'
|