@rokkit/ui 1.0.0-next.111 → 1.0.0-next.113

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 CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./types.js";
2
+ export { default as Button } from "./Button.svelte";
2
3
  export { default as Icon } from "./Icon.svelte";
3
4
  export { default as Item } from "./Item.svelte";
4
5
  export { default as Pill } from "./Pill.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/ui",
3
- "version": "1.0.0-next.111",
3
+ "version": "1.0.0-next.113",
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,9 +10,9 @@
10
10
  "access": "public"
11
11
  },
12
12
  "scripts": {
13
- "prepublishOnly": "tsc --project tsconfig.build.json",
13
+ "prepublishOnly": "bun clean && bun tsc --project tsconfig.build.json",
14
14
  "clean": "rm -rf dist",
15
- "build": "bun clean && bun prepublishOnly"
15
+ "build": "bun prepublishOnly"
16
16
  },
17
17
  "files": [
18
18
  "src/**/*.js",
@@ -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
+ import Icon from './Icon.svelte'
3
+ /**
4
+ * @typedef {Object} ButtonProps
5
+ * @property {'default' | 'primary' | 'secondary' | 'tertiary'} variant - The variant of the button.
6
+ * @property {'button' | 'submit' | 'reset'} type - The type of the button.
7
+ * @property {string} [label] - The label of the button.
8
+ * @property {string|import('svelte').Snippet} [leftIcon] - The left icon of the button.
9
+ * @property {string|import('svelte').Snippet} [rightIcon] - The right icon of the button.
10
+ * @property {import('svelte').Snippet} [children]
11
+ * @property {Function} onclick - The onclick event of the button.
12
+ * @property {Function} onsubmit - The onsubmit event of the button.
13
+ * @property {Function} onreset - The onreset event of the button.
14
+ */
15
+ /** @type {ButtonProps} */
16
+ let {
17
+ class: classes = '',
18
+ variant = 'default',
19
+ type = 'button',
20
+ leftIcon = null,
21
+ rightIcon = null,
22
+ label = null,
23
+ children = null,
24
+ description = null,
25
+ disabled = false,
26
+ onclick
27
+ } = $props()
28
+
29
+ const primary = $derived(variant === 'primary')
30
+ const secondary = $derived(variant === 'secondary')
31
+ const tertiary = $derived(variant === 'tertiary')
32
+ </script>
33
+
34
+ <button
35
+ class:primary
36
+ class:secondary
37
+ class:tertiary
38
+ class={classes}
39
+ {disabled}
40
+ {type}
41
+ {onclick}
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
@@ -33,6 +33,7 @@
33
33
 
34
34
  let emitter = $derived(createEmitter(events, ['click', 'change', 'mouseenter', 'mouseleave']))
35
35
  function handleClick(e) {
36
+ if (role === 'img') return
36
37
  e.preventDefault()
37
38
 
38
39
  if (!disabled) {
package/src/Node.svelte CHANGED
@@ -61,14 +61,14 @@
61
61
  {/each}
62
62
  <rk-item>
63
63
  <svelte:boundary>
64
- <!-- {#if template} -->
65
- {@render template(value)}
66
- {#snippet failed()}
64
+ {#if template}
65
+ {@render template(value)}
66
+ {#snippet failed()}
67
+ <Item {value} {fields} />
68
+ {/snippet}
69
+ {:else}
67
70
  <Item {value} {fields} />
68
- {/snippet}
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, getSnippet, FieldMapper } from '@rokkit/core'
3
+ import { noop, FieldMapper } from '@rokkit/core'
4
4
  import { keyboard } from '@rokkit/actions'
5
- import { defaultMapping } from './constants'
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 Template}
84
- <Template value={item} {fields} />
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'