@human-kit/svelte-components 1.0.0-alpha.8 → 1.0.0-alpha.9

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.
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { HTMLInputAttributes } from 'svelte/elements';
3
+ import { Input } from '../../input';
3
4
  import { useComboBoxContext } from '../root/context';
4
5
  import {
5
6
  shouldShowFocusVisible,
@@ -17,11 +18,26 @@
17
18
  class?: string;
18
19
  };
19
20
 
21
+ function composeEventHandlers<TEvent extends Event>(
22
+ internalHandler: ((event: TEvent) => void) | undefined,
23
+ externalHandler: ((event: TEvent) => void) | undefined
24
+ ): (event: TEvent) => void {
25
+ return (event: TEvent) => {
26
+ internalHandler?.(event);
27
+ externalHandler?.(event);
28
+ };
29
+ }
30
+
20
31
  let {
21
32
  'aria-label': ariaLabel,
22
33
  'aria-labelledby': ariaLabelledby,
23
34
  'aria-describedby': ariaDescribedby,
24
35
  class: className,
36
+ oninput: onInputExternal,
37
+ onfocus: onFocusExternal,
38
+ onmousedown: onMouseDownExternal,
39
+ onblur: onBlurExternal,
40
+ onkeydown: onKeyDownExternal,
25
41
  ...restProps
26
42
  }: ComboBoxInputProps = $props();
27
43
 
@@ -83,8 +99,8 @@
83
99
  }
84
100
  </script>
85
101
 
86
- <input
87
- bind:this={inputRef}
102
+ <Input
103
+ bind:element={inputRef}
88
104
  type="text"
89
105
  role="combobox"
90
106
  aria-autocomplete="list"
@@ -98,13 +114,13 @@
98
114
  aria-labelledby={ariaLabelledby}
99
115
  aria-describedby={ariaDescribedby}
100
116
  value={ctx.displayValue}
101
- disabled={ctx.isDisabled}
102
- readonly={ctx.isReadOnly}
103
- oninput={handleInput}
104
- onfocus={handleFocus}
105
- onmousedown={handleMouseDown}
106
- onblur={handleBlur}
107
- onkeydown={handleKeyDown}
117
+ isDisabled={ctx.isDisabled}
118
+ isReadOnly={ctx.isReadOnly}
119
+ oninput={composeEventHandlers(handleInput, onInputExternal ?? undefined)}
120
+ onfocus={composeEventHandlers(handleFocus, onFocusExternal ?? undefined)}
121
+ onmousedown={composeEventHandlers(handleMouseDown, onMouseDownExternal ?? undefined)}
122
+ onblur={composeEventHandlers(handleBlur, onBlurExternal ?? undefined)}
123
+ onkeydown={composeEventHandlers(handleKeyDown, onKeyDownExternal ?? undefined)}
108
124
  class={cn(
109
125
  'bg-depth-2 sunken placeholder:text-muted-foreground hover:bg-depth-1 focus:ring-border h-8 w-full rounded-xs border px-2 text-sm shadow-xs transition-all ease-out outline-none focus:ring focus:ring-offset-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
110
126
  className
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-kit/svelte-components",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0-alpha.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",