sheer-ui 0.4.0 → 0.4.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 (55) hide show
  1. package/package.json +1 -1
  2. package/src/lib/components/accordion/components/accordion-item.svelte +3 -3
  3. package/src/lib/components/accordion/components/accordion.svelte +29 -13
  4. package/src/lib/components/accordion/types.ts +3 -3
  5. package/src/lib/components/checkbox/components/checkbox-group.svelte +7 -5
  6. package/src/lib/components/checkbox/components/checkbox.svelte +12 -8
  7. package/src/lib/components/combobox/components/combobox.svelte +2 -2
  8. package/src/lib/components/combobox/select/components/select.svelte +2 -2
  9. package/src/lib/components/context-menu/components/context-menu-trigger.svelte +1 -1
  10. package/src/lib/components/date-field/date-field.svelte.ts +2 -3
  11. package/src/lib/components/menu/components/menu-checkbox-group.svelte +6 -4
  12. package/src/lib/components/menu/components/menu-checkbox-item.svelte +11 -7
  13. package/src/lib/components/menu/menu.svelte.ts +9 -18
  14. package/src/lib/components/menubar/menubar.svelte.ts +7 -6
  15. package/src/lib/components/navigation-menu/components/navigation-menu-content.svelte +1 -1
  16. package/src/lib/components/navigation-menu/components/navigation-menu-indicator.svelte +2 -2
  17. package/src/lib/components/navigation-menu/components/navigation-menu-trigger.svelte +1 -1
  18. package/src/lib/components/navigation-menu/navigation-menu.svelte.ts +57 -60
  19. package/src/lib/components/pagination/components/pagination-next-button.svelte +12 -7
  20. package/src/lib/components/pagination/components/pagination-page.svelte +15 -8
  21. package/src/lib/components/pagination/components/pagination-prev-button.svelte +12 -7
  22. package/src/lib/components/pagination/components/pagination.svelte +31 -18
  23. package/src/lib/components/pagination/pagination.svelte.ts +48 -64
  24. package/src/lib/components/pin-input/pin-input.svelte.ts +7 -8
  25. package/src/lib/components/pin-input/usePasswordManager.svelte.ts +2 -2
  26. package/src/lib/components/scroll-area/scroll-area.svelte.ts +9 -10
  27. package/src/lib/components/slider/components/slider.svelte +2 -1
  28. package/src/lib/components/tabs/components/tabs-content.svelte +12 -7
  29. package/src/lib/components/tabs/components/tabs-list.svelte +9 -6
  30. package/src/lib/components/tabs/components/tabs-trigger.svelte +15 -8
  31. package/src/lib/components/tabs/components/tabs.svelte +28 -17
  32. package/src/lib/components/tabs/tabs.svelte.ts +51 -67
  33. package/src/lib/components/time-field/time-field.svelte.ts +2 -2
  34. package/src/lib/components/toggle-group/components/toggle-group-item.svelte +15 -8
  35. package/src/lib/components/toggle-group/components/toggle-group.svelte +28 -16
  36. package/src/lib/components/toggle-group/toggle-group.svelte.ts +33 -35
  37. package/src/lib/components/toolbar/components/toolbar-group-item.svelte +15 -8
  38. package/src/lib/components/toolbar/components/toolbar-group.svelte +19 -14
  39. package/src/lib/components/toolbar/toolbar.svelte.ts +28 -30
  40. package/src/lib/components/tooltip/tooltip.svelte.ts +6 -27
  41. package/src/lib/internal/dismissible-layer/use-dismissable-layer.svelte.ts +3 -4
  42. package/src/lib/internal/floating-layer/use-floating-layer.svelte.ts +26 -30
  43. package/src/lib/internal/{roving-focus-group.ts → roving-focus-group.svelte.ts} +17 -19
  44. package/src/lib/internal/roving-focus-item.svelte.ts +12 -17
  45. package/src/lib/internal/selection.svelte.ts +55 -41
  46. package/src/lib/internal/{state-machine.ts → state-machine.svelte.ts} +6 -8
  47. package/src/lib/internal/timeout-fn.svelte.ts +6 -4
  48. package/src/lib/internal/tools/box.svelte.ts +5 -114
  49. package/src/lib/internal/tools/index.ts +1 -11
  50. package/src/lib/internal/tools/types.ts +0 -3
  51. package/src/lib/internal/typeahead.svelte.ts +9 -13
  52. package/src/lib/internal/types.ts +6 -0
  53. package/src/lib/internal/vaul/use-drawer-content.svelte.ts +2 -2
  54. package/src/lib/internal/vaul/use-drawer-root.svelte.ts +12 -7
  55. package/src/lib/components/accordion/accordion.svelte.ts +0 -43
@@ -1,10 +1,10 @@
1
1
  import { createContext } from 'svelte';
2
- import { attachRef, type ReadableBoxedValues, type WritableBoxedValues } from '../../internal/tools/index.js';
2
+ import { attachRef } from '../../internal/tools/index.js';
3
3
  import type { Page, PageItem } from './types.js';
4
- import type { BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from '../../internal/types.js';
4
+ import type { BitsKeyboardEvent, BitsMouseEvent, RefAttachment, RefOpts } from '../../internal/types.js';
5
5
  import { createBitsAttrs } from '../../internal/attrs.js';
6
6
  import { kbd } from '../../internal/kbd.js';
7
- import { RovingFocusGroup } from '../../internal/roving-focus-group.js';
7
+ import { RovingFocusGroup } from '../../internal/roving-focus-group.svelte.js';
8
8
  import { type Orientation } from '../../internal/index.js';
9
9
 
10
10
  const paginationAttrs = createBitsAttrs({
@@ -14,19 +14,14 @@ const paginationAttrs = createBitsAttrs({
14
14
 
15
15
  const [getPaginationRoot, setPaginationRoot] = createContext<PaginationRootState>();
16
16
 
17
- interface PaginationRootStateOpts
18
- extends
19
- WithRefOpts,
20
- ReadableBoxedValues<{
21
- count: number;
22
- perPage: number;
23
- siblingCount: number;
24
- orientation: Orientation;
25
- loop: boolean;
26
- }>,
27
- WritableBoxedValues<{
28
- page: number;
29
- }> {}
17
+ interface PaginationRootStateOpts extends RefOpts {
18
+ readonly count: number;
19
+ readonly perPage: number;
20
+ readonly siblingCount: number;
21
+ readonly orientation: Orientation;
22
+ readonly loop: boolean;
23
+ page: number;
24
+ }
30
25
 
31
26
  export class PaginationRootState {
32
27
  static create(opts: PaginationRootStateOpts) {
@@ -35,73 +30,66 @@ export class PaginationRootState {
35
30
  readonly opts: PaginationRootStateOpts;
36
31
  readonly attachment: RefAttachment;
37
32
  readonly totalPages = $derived.by(() => {
38
- if (this.opts.count.current === 0) return 1;
39
- return Math.ceil(this.opts.count.current / this.opts.perPage.current);
33
+ if (this.opts.count === 0) return 1;
34
+ return Math.ceil(this.opts.count / this.opts.perPage);
40
35
  });
41
36
  readonly range = $derived.by(() => {
42
- const start = (this.opts.page.current - 1) * this.opts.perPage.current;
43
- const end = Math.min(start + this.opts.perPage.current, this.opts.count.current);
37
+ const start = (this.opts.page - 1) * this.opts.perPage;
38
+ const end = Math.min(start + this.opts.perPage, this.opts.count);
44
39
  return { start: start + 1, end };
45
40
  });
46
41
  readonly pages = $derived.by(() =>
47
42
  getPageItems({
48
- page: this.opts.page.current,
43
+ page: this.opts.page,
49
44
  totalPages: this.totalPages,
50
- siblingCount: this.opts.siblingCount.current,
45
+ siblingCount: this.opts.siblingCount,
51
46
  }),
52
47
  );
53
- readonly hasPrevPage = $derived.by(() => this.opts.page.current > 1);
54
- readonly hasNextPage = $derived.by(() => this.opts.page.current < this.totalPages);
48
+ readonly hasPrevPage = $derived.by(() => this.opts.page > 1);
49
+ readonly hasNextPage = $derived.by(() => this.opts.page < this.totalPages);
55
50
 
56
51
  readonly rovingFocusGroup: RovingFocusGroup;
57
52
 
58
53
  constructor(opts: PaginationRootStateOpts) {
59
54
  this.opts = opts;
60
- this.attachment = attachRef(this.opts.ref);
55
+ this.attachment = attachRef<HTMLElement>((v) => (opts.ref = v));
61
56
  this.rovingFocusGroup = new RovingFocusGroup({
62
57
  candidateSelector: [paginationAttrs.selector('prev'), paginationAttrs.selector('page'), paginationAttrs.selector('next')].join(', '),
63
- rootNode: this.opts.ref,
64
- loop: this.opts.loop,
65
- orientation: this.opts.orientation,
58
+ rootNode: () => opts.ref,
59
+ loop: () => opts.loop,
60
+ orientation: () => opts.orientation,
66
61
  });
67
62
  }
68
63
 
69
- setPage(page: number) {
70
- this.opts.page.current = page;
71
- }
72
-
73
64
  prevPage() {
74
- this.opts.page.current = Math.max(this.opts.page.current - 1, 1);
65
+ this.opts.page = Math.max(this.opts.page - 1, 1);
75
66
  }
76
67
 
77
68
  nextPage() {
78
- this.opts.page.current = Math.min(this.opts.page.current + 1, this.totalPages);
69
+ this.opts.page = Math.min(this.opts.page + 1, this.totalPages);
79
70
  }
80
71
 
81
72
  readonly snippetProps = $derived.by(() => ({
82
73
  pages: this.pages,
83
74
  range: this.range,
84
- currentPage: this.opts.page.current,
75
+ currentPage: this.opts.page,
85
76
  }));
86
77
 
87
78
  readonly props = $derived.by(
88
79
  () =>
89
80
  ({
90
- id: this.opts.id.current,
91
- 'data-orientation': this.opts.orientation.current,
81
+ id: this.opts.id,
82
+ 'data-orientation': this.opts.orientation,
92
83
  [paginationAttrs.root]: '',
93
84
  ...this.attachment,
94
85
  }) as const,
95
86
  );
96
87
  }
97
88
 
98
- interface PaginationPageStateOpts
99
- extends
100
- WithRefOpts,
101
- ReadableBoxedValues<{
102
- page: Page;
103
- disabled: boolean;
104
- }> {}
89
+ interface PaginationPageStateOpts extends RefOpts {
90
+ readonly page: Page;
91
+ readonly disabled: boolean;
92
+ }
105
93
 
106
94
  export class PaginationPageState {
107
95
  static create(opts: PaginationPageStateOpts) {
@@ -110,38 +98,38 @@ export class PaginationPageState {
110
98
  readonly opts: PaginationPageStateOpts;
111
99
  readonly root: PaginationRootState;
112
100
  readonly attachment: RefAttachment;
113
- readonly #isSelected = $derived.by(() => this.opts.page.current.value === this.root.opts.page.current);
101
+ readonly #isSelected = $derived.by(() => this.opts.page.value === this.root.opts.page);
114
102
 
115
103
  constructor(opts: PaginationPageStateOpts, root: PaginationRootState) {
116
104
  this.opts = opts;
117
105
  this.root = root;
118
- this.attachment = attachRef(this.opts.ref);
106
+ this.attachment = attachRef<HTMLElement>((v) => (opts.ref = v));
119
107
 
120
108
  this.onclick = this.onclick.bind(this);
121
109
  this.onkeydown = this.onkeydown.bind(this);
122
110
  }
123
111
 
124
112
  onclick(e: BitsMouseEvent) {
125
- if (this.opts.disabled.current) return;
113
+ if (this.opts.disabled) return;
126
114
  if (e.button !== 0) return;
127
- this.root.setPage(this.opts.page.current.value);
115
+ this.root.opts.page = this.opts.page.value;
128
116
  }
129
117
 
130
118
  onkeydown(e: BitsKeyboardEvent) {
131
119
  if (e.key === kbd.SPACE || e.key === kbd.ENTER) {
132
120
  e.preventDefault();
133
- this.root.setPage(this.opts.page.current.value);
121
+ this.root.opts.page = this.opts.page.value;
134
122
  } else {
135
- this.root.rovingFocusGroup.handleKeydown(this.opts.ref.current, e);
123
+ this.root.rovingFocusGroup.handleKeydown(this.opts.ref, e);
136
124
  }
137
125
  }
138
126
 
139
127
  readonly props = $derived.by(
140
128
  () =>
141
129
  ({
142
- id: this.opts.id.current,
143
- 'aria-label': `Page ${this.opts.page.current.value}`,
144
- 'data-value': `${this.opts.page.current.value}`,
130
+ id: this.opts.id,
131
+ 'aria-label': `Page ${this.opts.page.value}`,
132
+ 'data-value': `${this.opts.page.value}`,
145
133
  'data-selected': this.#isSelected ? '' : undefined,
146
134
  [paginationAttrs.page]: '',
147
135
  //
@@ -156,12 +144,8 @@ export class PaginationPageState {
156
144
  // NEXT/PREV BUTTON
157
145
  //
158
146
 
159
- interface PaginationButtonStateOpts
160
- extends
161
- WithRefOpts,
162
- ReadableBoxedValues<{
163
- disabled: boolean;
164
- }> {
147
+ interface PaginationButtonStateOpts extends RefOpts {
148
+ readonly disabled: boolean;
165
149
  type: 'prev' | 'next';
166
150
  }
167
151
 
@@ -176,7 +160,7 @@ export class PaginationButtonState {
176
160
  constructor(opts: PaginationButtonStateOpts, root: PaginationRootState) {
177
161
  this.opts = opts;
178
162
  this.root = root;
179
- this.attachment = attachRef(this.opts.ref);
163
+ this.attachment = attachRef<HTMLElement>((v) => (opts.ref = v));
180
164
 
181
165
  this.onclick = this.onclick.bind(this);
182
166
  this.onkeydown = this.onkeydown.bind(this);
@@ -187,14 +171,14 @@ export class PaginationButtonState {
187
171
  }
188
172
 
189
173
  readonly #isDisabled = $derived.by(() => {
190
- if (this.opts.disabled.current) return true;
174
+ if (this.opts.disabled) return true;
191
175
  if (this.opts.type === 'prev') return !this.root.hasPrevPage;
192
176
  if (this.opts.type === 'next') return !this.root.hasNextPage;
193
177
  return false;
194
178
  });
195
179
 
196
180
  onclick(e: BitsMouseEvent) {
197
- if (this.opts.disabled.current) return;
181
+ if (this.opts.disabled) return;
198
182
  if (e.button !== 0) return;
199
183
  this.#action();
200
184
  }
@@ -204,14 +188,14 @@ export class PaginationButtonState {
204
188
  e.preventDefault();
205
189
  this.#action();
206
190
  } else {
207
- this.root.rovingFocusGroup.handleKeydown(this.opts.ref.current, e);
191
+ this.root.rovingFocusGroup.handleKeydown(this.opts.ref, e);
208
192
  }
209
193
  }
210
194
 
211
195
  readonly props = $derived.by(
212
196
  () =>
213
197
  ({
214
- id: this.opts.id.current,
198
+ id: this.opts.id,
215
199
  [paginationAttrs[this.opts.type]]: '',
216
200
  disabled: this.#isDisabled,
217
201
  //
@@ -5,7 +5,6 @@ import {
5
5
  DOMContext,
6
6
  type ReadableBoxedValues,
7
7
  type WritableBoxedValues,
8
- simpleBox,
9
8
  } from '../../internal/tools/index.js';
10
9
  import { usePasswordManagerBadge } from './usePasswordManager.svelte.js';
11
10
  import type { PinInputCell, PinInputRootProps as RootComponentProps } from './types.js';
@@ -80,7 +79,7 @@ export class PinInputRootState {
80
79
  readonly attachment: RefAttachment;
81
80
  readonly inputAttachment: RefAttachment<HTMLInputElement>;
82
81
  #isHoveringInput = $state(false);
83
- #isFocused = simpleBox(false);
82
+ isFocused = $state(false);
84
83
  #mirrorSelectionStart = $state<number | null>(null);
85
84
  #mirrorSelectionEnd = $state<number | null>(null);
86
85
 
@@ -129,7 +128,7 @@ export class PinInputRootState {
129
128
  this.#pwmb = usePasswordManagerBadge({
130
129
  containerRef: this.opts.ref,
131
130
  inputRef: this.opts.inputRef,
132
- isFocused: this.#isFocused,
131
+ isFocused: () => this.isFocused,
133
132
  pushPasswordManagerStrategy: this.opts.pushPasswordManagerStrategy,
134
133
  domContext: this.domContext,
135
134
  });
@@ -152,7 +151,7 @@ export class PinInputRootState {
152
151
 
153
152
  this.#onDocumentSelectionChange();
154
153
  if (this.domContext.getActiveElement() === input) {
155
- this.#isFocused.current = true;
154
+ this.isFocused = true;
156
155
  }
157
156
 
158
157
  if (!this.domContext.getElementById('pin-input-style')) {
@@ -386,7 +385,7 @@ export class PinInputRootState {
386
385
  this.#mirrorSelectionStart = start;
387
386
  this.#mirrorSelectionEnd = end;
388
387
  }
389
- this.#isFocused.current = true;
388
+ this.isFocused = true;
390
389
  };
391
390
 
392
391
  onpaste = (e: BitsEvent<ClipboardEvent>) => {
@@ -440,7 +439,7 @@ export class PinInputRootState {
440
439
  this.#prevInputMetadata.willSyntheticBlur = false;
441
440
  return;
442
441
  }
443
- this.#isFocused.current = false;
442
+ this.isFocused = false;
444
443
  };
445
444
 
446
445
  readonly inputProps = $derived.by(() => ({
@@ -469,7 +468,7 @@ export class PinInputRootState {
469
468
  readonly #cells = $derived.by(() =>
470
469
  Array.from({ length: this.opts.maxLength.current }).map((_, idx) => {
471
470
  const isActive =
472
- this.#isFocused.current &&
471
+ this.isFocused &&
473
472
  this.#mirrorSelectionStart !== null &&
474
473
  this.#mirrorSelectionEnd !== null &&
475
474
  ((this.#mirrorSelectionStart === this.#mirrorSelectionEnd && idx === this.#mirrorSelectionStart) ||
@@ -487,7 +486,7 @@ export class PinInputRootState {
487
486
 
488
487
  readonly snippetProps = $derived.by(() => ({
489
488
  cells: this.#cells,
490
- isFocused: this.#isFocused.current,
489
+ isFocused: this.isFocused,
491
490
  isHovering: this.#isHoveringInput,
492
491
  }));
493
492
  }
@@ -16,7 +16,7 @@ type UsePasswordManagerBadgeProps = {
16
16
  containerRef: WritableBox<HTMLElement | null>;
17
17
  inputRef: WritableBox<HTMLInputElement | null>;
18
18
  pushPasswordManagerStrategy: ReadableBox<PinInputRootPropsWithoutHTML['pushPasswordManagerStrategy']>;
19
- isFocused: ReadableBox<boolean>;
19
+ isFocused: () => boolean;
20
20
  domContext: DOMContext;
21
21
  };
22
22
 
@@ -91,7 +91,7 @@ export function usePasswordManagerBadge({
91
91
  });
92
92
 
93
93
  $effect(() => {
94
- const focused = isFocused.current || domContext.getActiveElement() === inputRef.current;
94
+ const focused = isFocused() || domContext.getActiveElement() === inputRef.current;
95
95
 
96
96
  if (pushPasswordManagerStrategy.current === 'none' || !focused) return;
97
97
 
@@ -7,14 +7,14 @@
7
7
 
8
8
  import { createEffectTimeout } from '../../internal/timeout-fn.svelte.js';
9
9
  import { createContext, getAbortSignal, untrack } from 'svelte';
10
- import { simpleBox, attachRef, DOMContext, getWindow, type ReadableBoxedValues } from '../../internal/tools/index.js';
10
+ import { attachRef, DOMContext, getWindow, type ReadableBoxedValues } from '../../internal/tools/index.js';
11
11
  import type { ScrollAreaType } from './types.js';
12
12
  import type { BitsPointerEvent, RefAttachment, WithRefOpts } from '../../internal/types.js';
13
13
  import { type Direction, type Orientation, mergeProps } from '../../internal/index.js';
14
14
  import { createId } from '../../internal/create-id.js';
15
15
  import { on } from 'svelte/events';
16
16
  import { createBitsAttrs } from '../../internal/attrs.js';
17
- import { StateMachine } from '../../internal/state-machine.js';
17
+ import { StateMachine } from '../../internal/state-machine.svelte.js';
18
18
  import { observeResizeMany } from '../../internal/svelte-resize-observer.svelte.js';
19
19
 
20
20
  const scrollAreaAttrs = createBitsAttrs({
@@ -97,14 +97,13 @@ export class ScrollAreaViewportState {
97
97
  readonly opts: ScrollAreaViewportStateOpts;
98
98
  readonly root: ScrollAreaRootState;
99
99
  readonly attachment: RefAttachment;
100
- #contentId = simpleBox('');
101
- #contentRef = simpleBox<HTMLElement | null>(null);
102
- readonly contentAttachment: RefAttachment = attachRef(this.#contentRef, (v) => (this.root.contentNode = v));
100
+ readonly #contentId: string;
101
+ readonly contentAttachment: RefAttachment = attachRef((v) => (this.root.contentNode = v));
103
102
 
104
103
  constructor(opts: ScrollAreaViewportStateOpts, root: ScrollAreaRootState) {
105
104
  this.opts = opts;
106
105
  this.root = root;
107
- this.#contentId.current = createId('content', opts.id.current);
106
+ this.#contentId = createId('content', opts.id.current);
108
107
  this.attachment = attachRef(opts.ref, (v) => (this.root.viewportNode = v));
109
108
  }
110
109
 
@@ -124,7 +123,7 @@ export class ScrollAreaViewportState {
124
123
  readonly contentProps = $derived.by(
125
124
  () =>
126
125
  ({
127
- id: this.#contentId.current,
126
+ id: this.#contentId,
128
127
  'data-scroll-area-content': '',
129
128
  /**
130
129
  * When horizontal scrollbar is visible: this element should be at least
@@ -252,7 +251,7 @@ export class ScrollAreaScrollbarScrollState {
252
251
  POINTER_ENTER: 'interacting',
253
252
  },
254
253
  });
255
- readonly isHidden = $derived.by(() => this.machine.state.current === 'hidden');
254
+ readonly isHidden = $derived.by(() => this.machine.state === 'hidden');
256
255
 
257
256
  constructor(scrollbar: ScrollAreaScrollbarState) {
258
257
  this.scrollbar = scrollbar;
@@ -261,7 +260,7 @@ export class ScrollAreaScrollbarScrollState {
261
260
  const debounceScrollend = createEffectTimeout(() => this.machine.dispatch('SCROLL_END'), () => 100);
262
261
 
263
262
  $effect(() => {
264
- const _state = this.machine.state.current;
263
+ const _state = this.machine.state;
265
264
  const scrollHideDelay = this.root.opts.scrollHideDelay.current;
266
265
  if (_state === 'idle') {
267
266
  const hideTimer = this.root.domContext.setTimeout(() => this.machine.dispatch('HIDE'), scrollHideDelay);
@@ -304,7 +303,7 @@ export class ScrollAreaScrollbarScrollState {
304
303
  readonly props = $derived.by(
305
304
  () =>
306
305
  ({
307
- 'data-state': this.machine.state.current === 'hidden' ? 'hidden' : 'visible',
306
+ 'data-state': this.machine.state === 'hidden' ? 'hidden' : 'visible',
308
307
  onpointerenter: this.onpointerenter,
309
308
  onpointerleave: this.onpointerleave,
310
309
  }) as const,
@@ -34,7 +34,8 @@
34
34
  }: SliderRootProps = $props();
35
35
 
36
36
  // Slider mode is construction-static: the root state chooses a single/multiple class once.
37
- const valueType = untrack(() => type);
37
+ // svelte-ignore state_referenced_locally
38
+ const valueType = type;
38
39
 
39
40
  const min = $derived.by(() => {
40
41
  if (minProp !== undefined) return minProp;
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { boxWith } from '../../../internal/tools/index.js';
3
2
  import { mergeProps } from '../../../internal/merge-props.js';
4
3
  import type { TabsContentProps } from '../types.js';
5
4
  import { TabsContentState } from '../tabs.svelte.js';
@@ -10,12 +9,18 @@
10
9
  let { children, child, id = createId(uid), ref = $bindable(null), value, ...restProps }: TabsContentProps = $props();
11
10
 
12
11
  const contentState = TabsContentState.create({
13
- value: boxWith(() => value),
14
- id: boxWith(() => id),
15
- ref: boxWith(
16
- () => ref,
17
- (v) => (ref = v),
18
- ),
12
+ get value() {
13
+ return value;
14
+ },
15
+ get id() {
16
+ return id;
17
+ },
18
+ get ref() {
19
+ return ref;
20
+ },
21
+ set ref(v) {
22
+ ref = v;
23
+ },
19
24
  });
20
25
 
21
26
  const mergedProps = $derived(mergeProps({ 'data-slot': 'tabs-content', class: 'flex-1 outline-none' }, restProps, contentState.props));
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { boxWith } from '../../../internal/tools/index.js';
3
2
  import { mergeProps } from '../../../internal/merge-props.js';
4
3
  import type { TabsListProps } from '../types.js';
5
4
  import { TabsListState } from '../tabs.svelte.js';
@@ -10,11 +9,15 @@
10
9
  let { child, children, id = createId(uid), ref = $bindable(null), ...restProps }: TabsListProps = $props();
11
10
 
12
11
  const listState = TabsListState.create({
13
- id: boxWith(() => id),
14
- ref: boxWith(
15
- () => ref,
16
- (v) => (ref = v),
17
- ),
12
+ get id() {
13
+ return id;
14
+ },
15
+ get ref() {
16
+ return ref;
17
+ },
18
+ set ref(v) {
19
+ ref = v;
20
+ },
18
21
  });
19
22
 
20
23
  const mergedProps = $derived(
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { boxWith } from '../../../internal/tools/index.js';
3
2
  import { mergeProps } from '../../../internal/merge-props.js';
4
3
  import type { TabsTriggerProps } from '../types.js';
5
4
  import { TabsTriggerState } from '../tabs.svelte.js';
@@ -19,13 +18,21 @@
19
18
  }: TabsTriggerProps = $props();
20
19
 
21
20
  const triggerState = TabsTriggerState.create({
22
- id: boxWith(() => id),
23
- disabled: boxWith(() => disabled ?? false),
24
- value: boxWith(() => value),
25
- ref: boxWith(
26
- () => ref,
27
- (v) => (ref = v),
28
- ),
21
+ get id() {
22
+ return id;
23
+ },
24
+ get disabled() {
25
+ return disabled ?? false;
26
+ },
27
+ get value() {
28
+ return value;
29
+ },
30
+ get ref() {
31
+ return ref;
32
+ },
33
+ set ref(v) {
34
+ ref = v;
35
+ },
29
36
  });
30
37
 
31
38
  const mergedProps = $derived(
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { boxWith } from '../../../internal/tools/index.js';
3
2
  import { mergeProps } from '../../../internal/merge-props.js';
4
3
  import type { TabsRootProps } from '../types.js';
5
4
  import { TabsRootState } from '../tabs.svelte.js';
@@ -22,22 +21,34 @@
22
21
  }: TabsRootProps = $props();
23
22
 
24
23
  const rootState = TabsRootState.create({
25
- id: boxWith(() => id),
26
- value: boxWith(
27
- () => value,
28
- (v) => {
29
- value = v;
30
- onValueChange(v);
31
- },
32
- ),
33
- orientation: boxWith(() => orientation),
34
- loop: boxWith(() => loop),
35
- activationMode: boxWith(() => activationMode),
36
- disabled: boxWith(() => disabled),
37
- ref: boxWith(
38
- () => ref,
39
- (v) => (ref = v),
40
- ),
24
+ get id() {
25
+ return id;
26
+ },
27
+ get value() {
28
+ return value;
29
+ },
30
+ set value(v) {
31
+ value = v;
32
+ onValueChange(v);
33
+ },
34
+ get orientation() {
35
+ return orientation;
36
+ },
37
+ get loop() {
38
+ return loop;
39
+ },
40
+ get activationMode() {
41
+ return activationMode;
42
+ },
43
+ get disabled() {
44
+ return disabled;
45
+ },
46
+ get ref() {
47
+ return ref;
48
+ },
49
+ set ref(v) {
50
+ ref = v;
51
+ },
41
52
  });
42
53
 
43
54
  const mergedProps = $derived(mergeProps({ 'data-slot': 'tabs', class: 'flex flex-col gap-2' }, restProps, rootState.props));