@rokkit/ui 1.0.0-next.112 → 1.0.0-next.114

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/ui",
3
- "version": "1.0.0-next.112",
3
+ "version": "1.0.0-next.114",
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": "bunx 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",
@@ -20,7 +20,6 @@
20
20
  "dist/**/*.d.ts"
21
21
  ],
22
22
  "exports": {
23
- "./src": "./src",
24
23
  "./package.json": "./package.json",
25
24
  "./utils": "./src/lib/index.js",
26
25
  ".": {
package/src/Button.svelte CHANGED
@@ -1,4 +1,5 @@
1
1
  <script>
2
+ import Icon from './Icon.svelte'
2
3
  /**
3
4
  * @typedef {Object} ButtonProps
4
5
  * @property {'default' | 'primary' | 'secondary' | 'tertiary'} variant - The variant of the button.
@@ -13,6 +14,7 @@
13
14
  */
14
15
  /** @type {ButtonProps} */
15
16
  let {
17
+ class: classes = '',
16
18
  variant = 'default',
17
19
  type = 'button',
18
20
  leftIcon = null,
@@ -20,9 +22,8 @@
20
22
  label = null,
21
23
  children = null,
22
24
  description = null,
23
- onclick,
24
- onsubmit,
25
- onreset
25
+ disabled = false,
26
+ onclick
26
27
  } = $props()
27
28
 
28
29
  const primary = $derived(variant === 'primary')
@@ -35,10 +36,9 @@
35
36
  class:secondary
36
37
  class:tertiary
37
38
  class={classes}
39
+ {disabled}
38
40
  {type}
39
41
  {onclick}
40
- {onsubmit}
41
- {onreset}
42
42
  aria-label={description ?? label}
43
43
  >
44
44
  {#if typeof leftIcon === 'string'}
@@ -12,10 +12,11 @@
12
12
 
13
13
  <span
14
14
  class="grid h-full w-4 min-w-4 grid-cols-2 grid-rows-2"
15
- class:line-empty={validatedType === 'empty'}
16
- class:line-child={validatedType === 'child'}
17
- class:line-sibling={validatedType === 'sibling'}
18
- class:line-last={validatedType === 'last'}
15
+ data-tag-tree-line
16
+ data-tag-line-empty={validatedType === 'empty' ? '' : undefined}
17
+ data-tag-line-child={validatedType === 'child' ? '' : undefined}
18
+ data-tag-line-sibling={validatedType === 'sibling' ? '' : undefined}
19
+ data-tag-line-last={validatedType === 'last' ? '' : undefined}
19
20
  >
20
21
  {#if validatedType === 'last'}
21
22
  {#if rtl}
@@ -24,7 +24,7 @@
24
24
  }
25
25
  </script>
26
26
 
27
- <Select {name} bind:value options={filtered} {...restProps} {fields} onselect={handleSelect}>
27
+ <Select {name} bind:value bind:options={filtered} {...restProps} {fields} onselect={handleSelect}>
28
28
  <span class="flex flex-grow">
29
29
  <input
30
30
  type="text"
package/src/Icon.svelte CHANGED
@@ -6,7 +6,7 @@
6
6
  * @property {any} name
7
7
  * @property {any} [state]
8
8
  * @property {string} [size]
9
- * @property {string} [role]
9
+ * @property {'img'|'button'|'checkbox'|'option'} [role]
10
10
  * @property {any} [label]
11
11
  * @property {boolean} [disabled]
12
12
  * @property {number} [tabindex]
@@ -19,6 +19,7 @@
19
19
 
20
20
  /** @type {Props} */
21
21
  let {
22
+ ref = $bindable(),
22
23
  class: classes = '',
23
24
  name,
24
25
  state = null,
@@ -37,7 +38,7 @@
37
38
  e.preventDefault()
38
39
 
39
40
  if (!disabled) {
40
- if (role === 'checkbox' || role === 'option') {
41
+ if (isCheckbox) {
41
42
  checked = !checked
42
43
  emitter?.change(checked)
43
44
  }
@@ -45,6 +46,7 @@
45
46
  }
46
47
  }
47
48
 
49
+ let isCheckbox = $derived(role === 'checkbox' || role === 'option')
48
50
  let validatedTabindex = $derived(role === 'img' || disabled ? -1 : tabindex)
49
51
  let ariaChecked = $derived(
50
52
  ['checkbox', 'option'].includes(role) ? (checked !== null ? checked : false) : null
@@ -53,18 +55,19 @@
53
55
 
54
56
  <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
55
57
  <rk-icon
58
+ bind:this={ref}
59
+ data-tag-icon
60
+ data-state={state}
61
+ data-tag-button={role === 'button' ? true : undefined}
62
+ data-tag-checkbox={isCheckbox ? true : undefined}
63
+ data-size={size}
64
+ data-disabled={disabled}
56
65
  class={classes}
57
- class:small={size === 'small'}
58
- class:medium={size === 'medium'}
59
- class:large={size === 'large'}
60
- class:disabled
61
66
  {role}
62
67
  aria-label={label ?? name}
63
68
  aria-checked={ariaChecked}
64
69
  onclick={handleClick}
65
70
  onkeydown={(e) => e.key === 'Enter' && e.currentTarget.click()}
66
- data-state={state}
67
- data-tag="icon"
68
71
  tabindex={validatedTabindex}
69
72
  onmouseenter={emitter.mouseenter}
70
73
  onnmouseleave={emitter.nmouseleave}
package/src/Link.svelte CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  /** @type {Props} */
14
14
  let { class: classes = '', value, mapping = new FieldMapper(), href = '#', ...rest } = $props()
15
- let url = $derived(mapping.get('url', value, href))
15
+ let url = $derived(mapping.get('href', value, href))
16
16
  let props = $derived({ ...mapping.get('props', value, {}), ...rest })
17
17
  </script>
18
18
 
@@ -32,7 +32,7 @@
32
32
  <list-editor class="flex {className}">
33
33
  <List
34
34
  bind:items={value}
35
- value={item}
35
+ bind:value={item}
36
36
  {fields}
37
37
  using={registry.components}
38
38
  on:select={handleSelect}
package/src/Select.svelte CHANGED
@@ -8,21 +8,22 @@
8
8
  // import ListItems from './ListItems.svelte'
9
9
  import Item from './Item.svelte'
10
10
 
11
- let className = ''
12
- export { className as class }
13
- export let name = null
14
- export let options = []
15
- /** @type {import('@rokkit/core').FieldMapping} */
16
- export let fields = {}
17
- export let using = {}
18
- export let value = null
19
- export let placeholder = ''
11
+ let {
12
+ class: className = '',
13
+ name = null,
14
+ options = $bindable([]),
15
+ fields,
16
+ using = {},
17
+ value = $bindable(null),
18
+ placeholder = '',
19
+ currentItem
20
+ } = $props()
20
21
 
21
- let activeIndex
22
- let open = false
23
- let offsetTop
22
+ let activeIndex = $state(-1)
23
+ let open = $state(false)
24
+ // let offsetTop
24
25
  let icons = defaultStateIcons.selector
25
- let activeItem
26
+ let activeItem = $state(null)
26
27
 
27
28
  function handleSelect() {
28
29
  open = false
@@ -51,10 +52,10 @@
51
52
  }
52
53
  }
53
54
 
54
- $: fields = { ...defaultFields, ...fields }
55
- $: using = { default: Item, ...using }
56
- $: activeIndex = options.findIndex((item) => item === value)
57
- $: offsetTop = activeItem?.offsetTop + activeItem?.clientHeight ?? 0
55
+ // $: fields = { ...defaultFields, ...fields }
56
+ // $: using = { default: Item, ...using }
57
+ // $: activeIndex = options.findIndex((item) => item === value)
58
+ let offsetTop = $derived(activeItem?.offsetTop + activeItem?.clientHeight ?? 0)
58
59
  </script>
59
60
 
60
61
  <input-select
@@ -65,27 +66,28 @@
65
66
  aria-label={name}
66
67
  use:dismissable
67
68
  use:navigable={{ horizontal: false, vertical: true }}
68
- on:focus={() => (open = true)}
69
- on:blur={() => (open = false)}
70
- on:dismiss={() => (open = false)}
71
- on:previous={handlePrevious}
72
- on:next={handleNext}
73
- on:select={handleKeySelect}
69
+ onfocus={() => (open = true)}
70
+ onblur={() => (open = false)}
71
+ ondismiss={() => (open = false)}
72
+ onprevious={handlePrevious}
73
+ onnext={handleNext}
74
+ onselect={handleKeySelect}
74
75
  >
75
- <!-- svelte-ignore a11y-click-events-have-key-events -->
76
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
76
77
  <selected-item
77
- on:click|stopPropagation={() => (open = !open)}
78
+ onclick={() => (open = !open)}
78
79
  class="flex w-full items-center"
79
80
  bind:this={activeItem}
80
81
  role="option"
81
82
  tabindex="-1"
82
83
  aria-selected={value !== null && !open}
83
84
  >
84
- <slot>
85
- <item>
86
- <svelte:component this={using.default} value={value ?? placeholder} {fields} />
87
- </item>
88
- </slot>
85
+ <item>
86
+ {#if currentItem}
87
+ {@render currentItem(value, fields)}
88
+ {/if}
89
+ <Item value={value ?? placeholder} {fields} />
90
+ </item>
89
91
  {#if open}
90
92
  <Icon name={icons.opened} label="opened" tabindex="-1" />
91
93
  {:else}
@@ -102,7 +104,14 @@
102
104
  {using}
103
105
  />
104
106
  </list> -->
105
- <List items={options} {fields} {using} bind:value on:select={handleSelect} tabindex="-1" />
107
+ <List
108
+ bind:items={options}
109
+ {fields}
110
+ {using}
111
+ bind:value
112
+ on:select={handleSelect}
113
+ tabindex="-1"
114
+ />
106
115
  </Slider>
107
116
  {/if}
108
117
  </input-select>
@@ -3,7 +3,7 @@
3
3
  import { fly, fade } from 'svelte/transition'
4
4
  import { cubicInOut } from 'svelte/easing'
5
5
 
6
- let { activeIndex = 0, columns = $bindable([]) } = $props()
6
+ let { activeIndex = $bindable(0), columns = $bindable([]) } = $props()
7
7
  let width = $state()
8
8
  let offset = $state(1)
9
9
 
@@ -20,6 +20,8 @@
20
20
  offset = -1
21
21
  }
22
22
  }
23
+
24
+ let activeColumn = $derived(columns[activeIndex])
23
25
  </script>
24
26
 
25
27
  <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
@@ -27,26 +29,22 @@
27
29
  use:swipeable
28
30
  onswipeleft={handlePrevious}
29
31
  onswiperight={handleNext}
30
- use:navigable
32
+ use:navigable={{ orientation: 'horizontal' }}
31
33
  onprevious={handlePrevious}
32
34
  onnext={handleNext}
33
35
  tabindex={0}
34
36
  class="relative grid h-full w-full overflow-hidden"
35
37
  bind:clientWidth={width}
36
38
  >
37
- {#each columns as column, index (index)}
38
- {#if index === activeIndex}
39
- <rk-segment
40
- class="slide absolute h-full w-full {column}"
41
- in:fly={{ x: offset * width, duration: 1000, easing: cubicInOut }}
42
- out:fade={{
43
- x: -1 * offset * width,
44
- duration: 1000,
45
- easing: cubicInOut
46
- }}
47
- >
48
- {column}
49
- </rk-segment>
50
- {/if}
51
- {/each}
39
+ <rk-segment
40
+ class="slide absolute h-full w-full"
41
+ in:fly={{ x: offset * width, duration: 1000, easing: cubicInOut }}
42
+ out:fade={{
43
+ x: -1 * offset * width,
44
+ duration: 1000,
45
+ easing: cubicInOut
46
+ }}
47
+ >
48
+ {activeColumn}
49
+ </rk-segment>
52
50
  </rk-container>