lithesome 0.14.0 → 0.14.2

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.
Files changed (91) hide show
  1. package/dist/components/Accordion/Accordion.svelte +20 -16
  2. package/dist/components/Accordion/AccordionButton.svelte +11 -5
  3. package/dist/components/Accordion/AccordionContent.svelte +16 -11
  4. package/dist/components/Accordion/AccordionHeading.svelte +9 -5
  5. package/dist/components/Accordion/AccordionItem.svelte +19 -14
  6. package/dist/components/Accordion/main.svelte.d.ts +5 -4
  7. package/dist/components/Accordion/main.svelte.js +9 -6
  8. package/dist/components/Accordion/types.d.ts +11 -2
  9. package/dist/components/Checkbox/Checkbox.svelte +22 -17
  10. package/dist/components/Checkbox/types.d.ts +8 -2
  11. package/dist/components/Combobox/Combobox.svelte +48 -43
  12. package/dist/components/Combobox/ComboboxArrow.svelte +8 -4
  13. package/dist/components/Combobox/ComboboxContent.svelte +20 -16
  14. package/dist/components/Combobox/ComboboxInput.svelte +20 -7
  15. package/dist/components/Combobox/ComboboxOption.svelte +31 -22
  16. package/dist/components/Combobox/main.svelte.d.ts +12 -8
  17. package/dist/components/Combobox/main.svelte.js +36 -25
  18. package/dist/components/Combobox/types.d.ts +37 -3
  19. package/dist/components/Hovercard/Hovercard.svelte +25 -20
  20. package/dist/components/Hovercard/HovercardArrow.svelte +8 -4
  21. package/dist/components/Hovercard/HovercardContent.svelte +19 -15
  22. package/dist/components/Hovercard/HovercardTrigger.svelte +12 -7
  23. package/dist/components/Hovercard/main.svelte.js +7 -4
  24. package/dist/components/Menu/Menu.svelte +20 -16
  25. package/dist/components/Menu/MenuArrow.svelte +8 -4
  26. package/dist/components/Menu/MenuContent.svelte +19 -15
  27. package/dist/components/Menu/MenuItem.svelte +26 -17
  28. package/dist/components/Menu/MenuTrigger.svelte +12 -7
  29. package/dist/components/Menu/main.svelte.d.ts +6 -5
  30. package/dist/components/Menu/main.svelte.js +11 -7
  31. package/dist/components/Menu/types.d.ts +17 -4
  32. package/dist/components/Modal/Modal.svelte +15 -11
  33. package/dist/components/Modal/ModalContent.svelte +12 -8
  34. package/dist/components/Modal/ModalDescription.svelte +9 -5
  35. package/dist/components/Modal/ModalOverlay.svelte +10 -6
  36. package/dist/components/Modal/ModalTitle.svelte +9 -5
  37. package/dist/components/Modal/main.svelte.js +1 -1
  38. package/dist/components/Pin/Pin.svelte +29 -24
  39. package/dist/components/Pin/PinInput.svelte +24 -14
  40. package/dist/components/Pin/PinValue.svelte +8 -4
  41. package/dist/components/Pin/main.svelte.d.ts +8 -8
  42. package/dist/components/Pin/main.svelte.js +14 -7
  43. package/dist/components/Pin/types.d.ts +39 -2
  44. package/dist/components/Popover/Popover.svelte +20 -16
  45. package/dist/components/Popover/PopoverArrow.svelte +8 -4
  46. package/dist/components/Popover/PopoverContent.svelte +20 -16
  47. package/dist/components/Popover/PopoverTrigger.svelte +12 -7
  48. package/dist/components/Popover/main.svelte.js +1 -1
  49. package/dist/components/Portal/Portal.svelte +14 -11
  50. package/dist/components/RadioGroup/RadioGroup.svelte +24 -20
  51. package/dist/components/RadioGroup/RadioGroupItem.svelte +27 -17
  52. package/dist/components/RadioGroup/main.svelte.d.ts +6 -5
  53. package/dist/components/RadioGroup/main.svelte.js +12 -6
  54. package/dist/components/RadioGroup/types.d.ts +18 -2
  55. package/dist/components/Select/Select.svelte +32 -28
  56. package/dist/components/Select/SelectArrow.svelte +8 -4
  57. package/dist/components/Select/SelectContent.svelte +19 -15
  58. package/dist/components/Select/SelectOption.svelte +30 -21
  59. package/dist/components/Select/SelectTrigger.svelte +13 -8
  60. package/dist/components/Select/SelectValue.svelte +14 -10
  61. package/dist/components/Select/main.svelte.d.ts +5 -4
  62. package/dist/components/Select/main.svelte.js +11 -7
  63. package/dist/components/Select/types.d.ts +17 -4
  64. package/dist/components/Slider/Slider.svelte +45 -35
  65. package/dist/components/Slider/SliderRange.svelte +9 -4
  66. package/dist/components/Slider/SliderThumb.svelte +12 -4
  67. package/dist/components/Slider/SliderValue.svelte +9 -4
  68. package/dist/components/Slider/main.svelte.d.ts +9 -8
  69. package/dist/components/Slider/main.svelte.js +16 -8
  70. package/dist/components/Slider/types.d.ts +35 -3
  71. package/dist/components/Switch/Switch.svelte +22 -17
  72. package/dist/components/Switch/types.d.ts +8 -2
  73. package/dist/components/Tabs/Tabs.svelte +20 -16
  74. package/dist/components/Tabs/TabsButton.svelte +28 -16
  75. package/dist/components/Tabs/TabsContent.svelte +11 -7
  76. package/dist/components/Tabs/TabsList.svelte +9 -5
  77. package/dist/components/Tabs/main.svelte.d.ts +5 -4
  78. package/dist/components/Tabs/main.svelte.js +9 -5
  79. package/dist/components/Tabs/types.d.ts +18 -2
  80. package/dist/components/Toast/Toast.svelte +9 -5
  81. package/dist/components/Toast/ToastMessage.svelte +9 -5
  82. package/dist/components/Toast/ToastTitle.svelte +9 -5
  83. package/dist/components/Toast/Toaster.svelte +15 -12
  84. package/dist/components/Toast/main.svelte.js +2 -2
  85. package/dist/internal/components/FloatingArrow.svelte +23 -12
  86. package/dist/internal/components/FloatingContent.svelte +46 -34
  87. package/dist/internal/helpers/context.svelte.js +1 -1
  88. package/dist/internal/helpers/utils.svelte.d.ts +1 -3
  89. package/dist/internal/helpers/utils.svelte.js +3 -5
  90. package/dist/internal/types.d.ts +1 -1
  91. package/package.json +77 -77
@@ -1,20 +1,24 @@
1
- <script lang="ts">import { useActions, classProp, stateValue } from "../../internal/index.js";
2
- import { createAccordionRootContext } from "./main.svelte.js";
3
- let {
4
- children,
5
- use = [],
6
- class: klass,
7
- value = $bindable(),
8
- self = $bindable(),
9
- single = $bindable(false),
10
- ...props
11
- } = $props();
12
- const ctx = createAccordionRootContext({
13
- single: stateValue(() => single),
14
- value: stateValue(() => value)
15
- });
1
+ <script lang="ts">
2
+ import { useActions, classProp, stateValue } from '../../internal/index.js';
3
+ import type { AccordionProps } from './types.js';
4
+ import { createAccordionRootContext } from './main.svelte.js';
5
+
6
+ let {
7
+ children,
8
+ use = [],
9
+ class: klass,
10
+ value = $bindable(),
11
+ self = $bindable(),
12
+ single = $bindable(false),
13
+ ...props
14
+ }: AccordionProps = $props();
15
+
16
+ const ctx = createAccordionRootContext({
17
+ single: stateValue(() => single),
18
+ value: stateValue(() => value)
19
+ });
16
20
  </script>
17
21
 
18
22
  <div bind:this={self} use:useActions={use} class={classProp(klass)} {...ctx.attrs} {...props}>
19
- {@render children({})}
23
+ {@render children?.({})}
20
24
  </div>
@@ -1,7 +1,13 @@
1
- <script lang="ts">import { useAccordionButton } from "./main.svelte.js";
2
- import { useActions, classProp } from "../../internal/index.js";
3
- let { children, class: klass, use = [], self = $bindable(), ...props } = $props();
4
- const ctx = useAccordionButton();
1
+ <script lang="ts">
2
+ import { useAccordionButton } from './main.svelte.js';
3
+ import { useActions, classProp } from '../../internal/index.js';
4
+ import type { AccordionButtonProps } from './types.js';
5
+
6
+ let { children, class: klass, use = [], self = $bindable(), onClick, ...props }: AccordionButtonProps = $props();
7
+
8
+ const ctx = useAccordionButton({
9
+ onClick
10
+ });
5
11
  </script>
6
12
 
7
13
  <button
@@ -12,5 +18,5 @@ const ctx = useAccordionButton();
12
18
  {...ctx.attrs}
13
19
  {...props}
14
20
  >
15
- {@render children(ctx.state)}
21
+ {@render children?.(ctx.state)}
16
22
  </button>
@@ -1,22 +1,27 @@
1
- <script lang="ts">import { useAccordionContent } from "./main.svelte.js";
2
- import { useActions, getTransition, classProp } from "../../internal/index.js";
3
- let { children, class: klass, use = [], self = $bindable(), transition, ...props } = $props();
4
- const ctx = useAccordionContent();
5
- const { inTransition, outTransition } = getTransition(transition);
6
- const attrs = $derived({
7
- ...ctx.attrs,
8
- class: classProp(klass)
9
- });
1
+ <script lang="ts">
2
+ import { useAccordionContent } from './main.svelte.js';
3
+ import { useActions, getTransition, classProp } from '../../internal/index.js';
4
+ import type { AccordionContentProps } from './types.js';
5
+
6
+ let { children, class: klass, use = [], self = $bindable(), transition, ...props }: AccordionContentProps = $props();
7
+
8
+ const ctx = useAccordionContent();
9
+
10
+ const { inTransition, outTransition } = getTransition(transition);
11
+ const attrs = $derived({
12
+ ...ctx.attrs,
13
+ class: classProp(klass)
14
+ } as const);
10
15
  </script>
11
16
 
12
17
  {#if inTransition && outTransition && ctx.item.Active}
13
18
  {@const { config: inConf, transition: inFn } = inTransition}
14
19
  {@const { config: outConf, transition: outFn } = outTransition}
15
20
  <div bind:this={self} use:useActions={use} in:inFn={inConf} out:outFn={outConf} {...attrs} {...props}>
16
- {@render children({})}
21
+ {@render children?.({})}
17
22
  </div>
18
23
  {:else if ctx.item.Active}
19
24
  <div bind:this={self} use:useActions={use} {...attrs} {...props}>
20
- {@render children({})}
25
+ {@render children?.({})}
21
26
  </div>
22
27
  {/if}
@@ -1,9 +1,13 @@
1
- <script lang="ts">import { useAccordionHeading } from "./main.svelte.js";
2
- import { useActions, classProp } from "../../internal/index.js";
3
- let { children, class: klass, use = [], level = 3, self = $bindable(), ...props } = $props();
4
- const ctx = useAccordionHeading({ level });
1
+ <script lang="ts">
2
+ import { useAccordionHeading } from './main.svelte.js';
3
+ import { useActions, classProp } from '../../internal/index.js';
4
+ import type { AccordionHeadingProps } from './types.js';
5
+
6
+ let { children, class: klass, use = [], level = 3, self = $bindable(), ...props }: AccordionHeadingProps = $props();
7
+
8
+ const ctx = useAccordionHeading({ level });
5
9
  </script>
6
10
 
7
11
  <div bind:this={self} use:useActions={use} class={classProp(klass)} {...ctx.attrs} {...props}>
8
- {@render children({})}
12
+ {@render children?.({})}
9
13
  </div>
@@ -1,18 +1,23 @@
1
- <script lang="ts">import { createAccordionItemContext } from "./main.svelte.js";
2
- import { useActions, classProp, stateValue } from "../../internal/index.js";
3
- let {
4
- children,
5
- class: klass,
6
- use = [],
7
- self = $bindable(),
8
- disabled = $bindable(false),
9
- ...props
10
- } = $props();
11
- const ctx = createAccordionItemContext({
12
- disabled: stateValue(() => disabled)
13
- });
1
+ <script lang="ts">
2
+ import { createAccordionItemContext } from './main.svelte.js';
3
+ import { useActions, classProp, stateValue } from '../../internal/index.js';
4
+
5
+ import type { AccordionItemProps } from './types.js';
6
+
7
+ let {
8
+ children,
9
+ class: klass,
10
+ use = [],
11
+ self = $bindable(),
12
+ disabled = $bindable(false),
13
+ ...props
14
+ }: AccordionItemProps = $props();
15
+
16
+ const ctx = createAccordionItemContext({
17
+ disabled: stateValue(() => disabled)
18
+ });
14
19
  </script>
15
20
 
16
21
  <div bind:this={self} use:useActions={use} {...ctx.attrs} class={classProp(klass, ctx.state)} {...props}>
17
- {@render children(ctx.state)}
22
+ {@render children?.(ctx.state)}
18
23
  </div>
@@ -1,4 +1,5 @@
1
- import { type StateValues } from '../../internal/index.js';
1
+ import { type Handler, type StateValues } from '../../internal/index.js';
2
+ import type { AccordionButtonEvents } from './types.js';
2
3
  interface Item {
3
4
  id: string;
4
5
  disabled: boolean;
@@ -56,7 +57,7 @@ declare class AccordionButton {
56
57
  #private;
57
58
  root: AccordionRoot;
58
59
  item: AccordionItem;
59
- constructor(item: AccordionItem, root: AccordionRoot);
60
+ constructor(item: AccordionItem, root: AccordionRoot, events: AccordionButtonEvents);
60
61
  attrs: {
61
62
  readonly 'aria-expanded': boolean;
62
63
  readonly 'aria-disabled': boolean;
@@ -64,7 +65,7 @@ declare class AccordionButton {
64
65
  readonly tabindex: 0 | -1;
65
66
  readonly 'data-accordionbutton': "";
66
67
  readonly 'data-active': true | undefined;
67
- readonly onclick: () => void;
68
+ readonly onclick: Handler<MouseEvent, HTMLButtonElement> | undefined;
68
69
  };
69
70
  state: {
70
71
  active: boolean;
@@ -88,6 +89,6 @@ declare class AccordionContent {
88
89
  export declare const createAccordionRootContext: (props: AccordionRootProps) => AccordionRoot;
89
90
  export declare const createAccordionItemContext: (props: AccordionItemProps) => AccordionItem;
90
91
  export declare const useAccordionHeading: (props: AccordionHeadingProps) => AccordionHeading;
91
- export declare const useAccordionButton: () => AccordionButton;
92
+ export declare const useAccordionButton: (events: AccordionButtonEvents) => AccordionButton;
92
93
  export declare const useAccordionContent: () => AccordionContent;
93
94
  export {};
@@ -1,6 +1,6 @@
1
1
  import { buildContext, createUID } from '../../internal/index.js';
2
2
  class AccordionRoot {
3
- uid = createUID('accordion').uid;
3
+ uid = createUID('accordion');
4
4
  $value;
5
5
  $single;
6
6
  items = $state([]);
@@ -26,7 +26,7 @@ class AccordionRoot {
26
26
  }));
27
27
  }
28
28
  class AccordionItem {
29
- uid = createUID('item').uid;
29
+ uid = createUID('item');
30
30
  root;
31
31
  $disabled;
32
32
  Active = $derived.by(() => this.root.activeItems.includes(this.uid()) || false);
@@ -63,13 +63,16 @@ class AccordionHeading {
63
63
  class AccordionButton {
64
64
  root;
65
65
  item;
66
- constructor(item, root) {
66
+ #events;
67
+ constructor(item, root, events) {
67
68
  this.root = root;
68
69
  this.item = item;
70
+ this.#events = events;
69
71
  }
70
- #handleClick = () => {
72
+ #handleClick = (e) => {
71
73
  if (this.item.$disabled.val)
72
74
  return;
75
+ this.#events.onClick?.(e);
73
76
  this.root.toggleActiveItem(this.item.uid());
74
77
  };
75
78
  attrs = $derived.by(() => ({
@@ -118,8 +121,8 @@ export const createAccordionItemContext = (props) => {
118
121
  export const useAccordionHeading = (props) => {
119
122
  return rootContext.register(AccordionHeading, props);
120
123
  };
121
- export const useAccordionButton = () => {
122
- return itemContext.register(AccordionButton, rootContext.getContext());
124
+ export const useAccordionButton = (events) => {
125
+ return itemContext.register(AccordionButton, rootContext.getContext(), events);
123
126
  };
124
127
  export const useAccordionContent = () => {
125
128
  return itemContext.register(AccordionContent, rootContext.getContext());
@@ -1,4 +1,4 @@
1
- import type { Props, Transition } from '../../internal/index.js';
1
+ import type { Props, Handler, Transition } from '../../internal/index.js';
2
2
  export interface AccordionProps extends Props<HTMLDivElement> {
3
3
  /** The value of the active item. */
4
4
  value?: string;
@@ -23,7 +23,16 @@ interface AccordionButtonState {
23
23
  /** True if the item is disabled. */
24
24
  disabled: boolean;
25
25
  }
26
- export interface AccordionButtonProps extends Props<HTMLButtonElement, AccordionButtonState> {
26
+ export interface AccordionButtonEvents {
27
+ /**
28
+ * Add your own custom logic to the click event.\
29
+ * Using the regular `onclick` event will overwrite the event used and cause the component to fail.
30
+ *
31
+ * Event will **NOT** be fired if the component is disabled.
32
+ */
33
+ onClick?: Handler<MouseEvent, HTMLButtonElement>;
34
+ }
35
+ export interface AccordionButtonProps extends Props<HTMLButtonElement, AccordionButtonState>, AccordionButtonEvents {
27
36
  }
28
37
  interface AccordionItemState {
29
38
  /** True if the item is opened. */
@@ -1,20 +1,25 @@
1
- <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
- let {
3
- children,
4
- class: klass,
5
- use = [],
6
- self = $bindable(),
7
- checked = $bindable(false),
8
- required = false,
9
- disabled = $bindable(false),
10
- onClick,
11
- ...props
12
- } = $props();
13
- const handleClick = (e) => {
14
- onClick?.(e);
15
- if (disabled) return;
16
- checked = checked === "mixed" ? true : !checked;
17
- };
1
+ <script lang="ts">
2
+ import { useActions, classProp } from '../../internal/index.js';
3
+ import type { CheckboxProps } from './types.js';
4
+
5
+ let {
6
+ children,
7
+ class: klass,
8
+ use = [],
9
+ self = $bindable(),
10
+ checked = $bindable(false),
11
+ required = false,
12
+ disabled = $bindable(false),
13
+ onClick,
14
+ ...props
15
+ }: CheckboxProps = $props();
16
+
17
+ const handleClick: typeof onClick = (e) => {
18
+ if (disabled) return;
19
+ onClick?.(e);
20
+
21
+ checked = checked === 'mixed' ? true : !checked;
22
+ };
18
23
  </script>
19
24
 
20
25
  <button
@@ -1,16 +1,22 @@
1
- import type { Handler, PropsMaybeChildren } from '../../internal/index.js';
1
+ import type { Handler, Props } from '../../internal/index.js';
2
2
  export type Checked = boolean | 'mixed';
3
3
  interface CheckboxState {
4
4
  /** If the checkbox is checked or not. */
5
5
  checked: Checked;
6
6
  }
7
- export interface CheckboxProps extends PropsMaybeChildren<HTMLButtonElement, CheckboxState> {
7
+ export interface CheckboxProps extends Props<HTMLButtonElement, CheckboxState> {
8
8
  /** If the checkbox is checked or not. */
9
9
  checked?: Checked;
10
10
  /** Adds aria attributes. */
11
11
  required?: boolean;
12
12
  /** Disabled the checkbox, disallowing the internal events. */
13
13
  disabled?: boolean;
14
+ /**
15
+ * Add your own custom logic to the click event.\
16
+ * Using the regular `onclick` event will overwrite the event used and cause the component to fail.
17
+ *
18
+ * Event will **NOT** be fired if the component is disabled.
19
+ */
14
20
  onClick?: Handler<MouseEvent, HTMLButtonElement>;
15
21
  }
16
22
  export {};
@@ -1,47 +1,52 @@
1
- <script lang="ts">import { useActions, classProp, stateValue } from "../../internal/index.js";
2
- import { createRootContext } from "./main.svelte.js";
3
- let {
4
- children,
5
- use = [],
6
- class: klass,
7
- value = $bindable(),
8
- label = $bindable(),
9
- touched = $bindable(false),
10
- disabled = $bindable(false),
11
- visible = $bindable(true),
12
- self = $bindable(),
13
- onChange,
14
- ...props
15
- } = $props();
16
- const multiple = Array.isArray(value);
17
- const ctx = createRootContext({
18
- value: stateValue(
19
- () => value,
20
- (v) => {
21
- value = v;
22
- onChange?.({ value: v });
23
- }
24
- ),
25
- disabled: stateValue(() => disabled),
26
- label: stateValue(
27
- () => label || self?.textContent?.trim() || "",
28
- (v) => {
29
- label = v;
30
- onChange?.({ label: v });
31
- }
32
- ),
33
- multiple: stateValue(() => multiple),
34
- touched: stateValue(
35
- () => touched,
36
- (v) => touched = v
37
- ),
38
- visible: stateValue(
39
- () => visible,
40
- (v) => visible = v
41
- )
42
- });
1
+ <script lang="ts">
2
+ import { useActions, classProp, stateValue } from '../../internal/index.js';
3
+ import { createRootContext } from './main.svelte.js';
4
+ import type { ComboboxProps } from './types.js';
5
+
6
+ let {
7
+ children,
8
+ use = [],
9
+ class: klass,
10
+ value = $bindable(),
11
+ label = $bindable(),
12
+ touched = $bindable(false),
13
+ disabled = $bindable(false),
14
+ visible = $bindable(true),
15
+ controlled,
16
+ self = $bindable(),
17
+ onChange,
18
+ ...props
19
+ }: ComboboxProps = $props();
20
+
21
+ const ctx = createRootContext({
22
+ value: stateValue(
23
+ () => value,
24
+ (v) => {
25
+ value = v;
26
+ onChange?.({ value: v });
27
+ }
28
+ ),
29
+ disabled: stateValue(() => disabled),
30
+ label: stateValue(
31
+ () => label || self?.textContent?.trim() || '',
32
+ (v) => {
33
+ label = v;
34
+ onChange?.({ label: v });
35
+ }
36
+ ),
37
+ multiple: stateValue(() => Array.isArray(value)),
38
+ touched: stateValue(
39
+ () => touched,
40
+ (v) => (touched = v)
41
+ ),
42
+ visible: stateValue(
43
+ () => visible,
44
+ (v) => (visible = v)
45
+ ),
46
+ controlled: stateValue(() => controlled)
47
+ });
43
48
  </script>
44
49
 
45
50
  <div bind:this={self} use:useActions={use} class={classProp(klass, ctx.state)} {...ctx.attrs} {...props}>
46
- {@render children(ctx.state)}
51
+ {@render children?.(ctx.state)}
47
52
  </div>
@@ -1,7 +1,11 @@
1
- <script lang="ts">import { FloatingArrow } from "../../internal/index.js";
2
- import { useComboboxArrow } from "./main.svelte.js";
3
- let { class: klass, use = [], self = $bindable(), ...props } = $props();
4
- const ctx = useComboboxArrow();
1
+ <script lang="ts">
2
+ import { FloatingArrow } from '../../internal/index.js';
3
+ import { useComboboxArrow } from './main.svelte.js';
4
+ import type { ComboboxArrowProps } from './types.js';
5
+
6
+ let { class: klass, use = [], self = $bindable(), ...props }: ComboboxArrowProps = $props();
7
+
8
+ const ctx = useComboboxArrow();
5
9
  </script>
6
10
 
7
11
  <FloatingArrow {ctx} component="Combobox" class={klass} {...props} />
@@ -1,24 +1,28 @@
1
- <script lang="ts">import { FloatingContent } from "../../internal/index.js";
2
- import { useComboboxContent } from "./main.svelte.js";
3
- let {
4
- children,
5
- transition,
6
- use = [],
7
- portalTarget = "body",
8
- sameWidth = false,
9
- class: klass,
10
- self = $bindable(),
11
- placement = "bottom",
12
- constrainViewport = false,
13
- ...props
14
- } = $props();
15
- const ctx = useComboboxContent();
1
+ <script lang="ts">
2
+ import { FloatingContent } from '../../internal/index.js';
3
+ import { useComboboxContent } from './main.svelte.js';
4
+ import type { ComboboxContentProps } from './types.js';
5
+
6
+ let {
7
+ children,
8
+ transition,
9
+ use = [],
10
+ portalTarget = 'body',
11
+ sameWidth = false,
12
+ class: klass,
13
+ self = $bindable(),
14
+ placement = 'bottom',
15
+ constrainViewport = false,
16
+ ...props
17
+ }: ComboboxContentProps = $props();
18
+
19
+ const ctx = useComboboxContent();
16
20
  </script>
17
21
 
18
22
  <FloatingContent
19
23
  {children}
20
24
  componentName="Combobox"
21
- visible={ctx.root.$visible.val}
25
+ visible={ctx.root.SuperVisible}
22
26
  {ctx}
23
27
  {transition}
24
28
  {use}
@@ -1,10 +1,23 @@
1
- <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
- import { useComboboxInput } from "./main.svelte.js";
3
- let { class: klass, use = [], value = $bindable(), self = $bindable(), ...props } = $props();
4
- const ctx = useComboboxInput();
5
- $effect(() => {
6
- if (self) ctx.registerTrigger(self);
7
- });
1
+ <script lang="ts">
2
+ import { useActions, classProp } from '../../internal/index.js';
3
+ import { useComboboxInput } from './main.svelte.js';
4
+ import type { ComboboxInputProps } from './types.js';
5
+
6
+ let {
7
+ class: klass,
8
+ use = [],
9
+ value = $bindable(),
10
+ self = $bindable(),
11
+ onClick,
12
+ onKeydown,
13
+ ...props
14
+ }: ComboboxInputProps = $props();
15
+
16
+ const ctx = useComboboxInput({ onClick, onKeydown });
17
+
18
+ $effect(() => {
19
+ if (self) ctx.registerTrigger(self);
20
+ });
8
21
  </script>
9
22
 
10
23
  <input bind:this={self} use:useActions={use} class={classProp(klass, ctx.state)} bind:value {...ctx.attrs} {...props} />
@@ -1,24 +1,33 @@
1
- <script lang="ts">import { useActions, classProp, stateValue } from "../../internal/index.js";
2
- import { useComboboxOption } from "./main.svelte.js";
3
- let {
4
- children,
5
- class: klass,
6
- use = [],
7
- value,
8
- label,
9
- self = $bindable(),
10
- disabled = $bindable(false),
11
- onClick,
12
- onFocus,
13
- onMouseover,
14
- ...props
15
- } = $props();
16
- let optionEl;
17
- const ctx = useComboboxOption({
18
- disabled: stateValue(() => disabled),
19
- value: stateValue(() => value),
20
- label: stateValue(() => label || self?.textContent?.trim() || "")
21
- });
1
+ <script lang="ts">
2
+ import { useActions, classProp, stateValue } from '../../internal/index.js';
3
+ import { useComboboxOption } from './main.svelte.js';
4
+ import type { ComboboxElement, ComboboxOptionProps } from './types.js';
5
+
6
+ let {
7
+ children,
8
+ class: klass,
9
+ use = [],
10
+ value,
11
+ label,
12
+ self = $bindable(),
13
+ disabled = $bindable(false),
14
+ onClick,
15
+ onMouseover,
16
+ ...props
17
+ }: ComboboxOptionProps = $props();
18
+ let optionEl: ComboboxElement;
19
+
20
+ const ctx = useComboboxOption(
21
+ {
22
+ disabled: stateValue(() => disabled),
23
+ value: stateValue(() => value),
24
+ label: stateValue(() => label || self?.textContent?.trim() || '')
25
+ },
26
+ {
27
+ onClick,
28
+ onMouseover
29
+ }
30
+ );
22
31
  </script>
23
32
 
24
33
  <button
@@ -29,5 +38,5 @@ const ctx = useComboboxOption({
29
38
  {...ctx.attrs}
30
39
  {...props}
31
40
  >
32
- {@render children(ctx.state)}
41
+ {@render children?.(ctx.state)}
33
42
  </button>