@sprawlify/primitives 0.0.112 → 0.0.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.
Files changed (92) hide show
  1. package/dist/{date-utils-Dz9DZPcZ.cjs → date-utils-B-dqorZV.cjs} +48 -13
  2. package/dist/{date-utils-BqOQP2-U.mjs → date-utils-BdeeOQRI.mjs} +43 -14
  3. package/dist/date-utils.cjs +2 -1
  4. package/dist/date-utils.d.cts +6 -5
  5. package/dist/date-utils.d.mts +2 -2
  6. package/dist/date-utils.mjs +2 -2
  7. package/dist/{index-6cEVkXqi.d.mts → index-BfUngXif.d.mts} +6 -5
  8. package/dist/machines/accordion/index.d.cts +1 -1
  9. package/dist/machines/accordion/index.d.mts +1 -1
  10. package/dist/machines/angle-slider/index.cjs +64 -24
  11. package/dist/machines/angle-slider/index.d.cts +1 -1
  12. package/dist/machines/angle-slider/index.d.mts +1 -1
  13. package/dist/machines/angle-slider/index.mjs +65 -25
  14. package/dist/machines/carousel/index.d.cts +1 -1
  15. package/dist/machines/carousel/index.d.mts +1 -1
  16. package/dist/machines/cascade-select/index.cjs +44 -19
  17. package/dist/machines/cascade-select/index.d.cts +13 -10
  18. package/dist/machines/cascade-select/index.d.mts +13 -10
  19. package/dist/machines/cascade-select/index.mjs +45 -20
  20. package/dist/machines/checkbox/index.d.cts +1 -1
  21. package/dist/machines/checkbox/index.d.mts +1 -1
  22. package/dist/machines/clipboard/index.d.cts +1 -1
  23. package/dist/machines/clipboard/index.d.mts +1 -1
  24. package/dist/machines/collapsible/index.d.cts +1 -1
  25. package/dist/machines/collapsible/index.d.mts +1 -1
  26. package/dist/machines/color-picker/index.d.cts +1 -1
  27. package/dist/machines/color-picker/index.d.mts +1 -1
  28. package/dist/machines/combobox/index.cjs +13 -11
  29. package/dist/machines/combobox/index.d.cts +1 -1
  30. package/dist/machines/combobox/index.d.mts +1 -1
  31. package/dist/machines/combobox/index.mjs +14 -12
  32. package/dist/machines/date-picker/index.cjs +46 -25
  33. package/dist/machines/date-picker/index.d.cts +3 -2
  34. package/dist/machines/date-picker/index.d.mts +4 -3
  35. package/dist/machines/date-picker/index.mjs +47 -26
  36. package/dist/machines/dialog/index.d.cts +1 -1
  37. package/dist/machines/dialog/index.d.mts +1 -1
  38. package/dist/machines/drawer/index.d.cts +1 -1
  39. package/dist/machines/drawer/index.d.mts +1 -1
  40. package/dist/machines/dropdown-menu/index.d.cts +1 -1
  41. package/dist/machines/dropdown-menu/index.d.mts +1 -1
  42. package/dist/machines/editable/index.d.cts +1 -1
  43. package/dist/machines/editable/index.d.mts +1 -1
  44. package/dist/machines/file-upload/index.d.cts +1 -1
  45. package/dist/machines/file-upload/index.d.mts +1 -1
  46. package/dist/machines/floating-panel/index.d.cts +1 -1
  47. package/dist/machines/floating-panel/index.d.mts +1 -1
  48. package/dist/machines/image-cropper/index.d.cts +1 -1
  49. package/dist/machines/image-cropper/index.d.mts +1 -1
  50. package/dist/machines/listbox/index.d.cts +1 -1
  51. package/dist/machines/listbox/index.d.mts +1 -1
  52. package/dist/machines/marquee/index.d.cts +3 -3
  53. package/dist/machines/marquee/index.d.mts +3 -3
  54. package/dist/machines/navigation-menu/index.d.cts +1 -1
  55. package/dist/machines/navigation-menu/index.d.mts +1 -1
  56. package/dist/machines/number-input/index.d.cts +1 -1
  57. package/dist/machines/number-input/index.d.mts +1 -1
  58. package/dist/machines/pagination/index.d.cts +1 -1
  59. package/dist/machines/pagination/index.d.mts +1 -1
  60. package/dist/machines/password-input/index.d.cts +1 -1
  61. package/dist/machines/password-input/index.d.mts +1 -1
  62. package/dist/machines/popover/index.d.cts +1 -1
  63. package/dist/machines/popover/index.d.mts +1 -1
  64. package/dist/machines/progress/index.d.cts +1 -1
  65. package/dist/machines/progress/index.d.mts +1 -1
  66. package/dist/machines/radio-group/index.d.cts +1 -1
  67. package/dist/machines/radio-group/index.d.mts +1 -1
  68. package/dist/machines/select/index.d.cts +1 -1
  69. package/dist/machines/select/index.d.mts +1 -1
  70. package/dist/machines/signature-pad/index.d.cts +1 -1
  71. package/dist/machines/signature-pad/index.d.mts +1 -1
  72. package/dist/machines/slider/index.d.cts +1 -1
  73. package/dist/machines/slider/index.d.mts +1 -1
  74. package/dist/machines/splitter/index.d.cts +1 -1
  75. package/dist/machines/splitter/index.d.mts +1 -1
  76. package/dist/machines/steps/index.d.cts +1 -1
  77. package/dist/machines/steps/index.d.mts +1 -1
  78. package/dist/machines/switch/index.d.cts +1 -1
  79. package/dist/machines/switch/index.d.mts +1 -1
  80. package/dist/machines/tabs/index.d.cts +1 -1
  81. package/dist/machines/tabs/index.d.mts +1 -1
  82. package/dist/machines/tags-input/index.d.cts +1 -1
  83. package/dist/machines/tags-input/index.d.mts +1 -1
  84. package/dist/machines/timer/index.d.cts +1 -1
  85. package/dist/machines/timer/index.d.mts +1 -1
  86. package/dist/machines/toast/index.d.cts +1 -1
  87. package/dist/machines/toast/index.d.mts +1 -1
  88. package/dist/machines/tour/index.d.cts +1 -1
  89. package/dist/machines/tour/index.d.mts +1 -1
  90. package/dist/machines/tree-view/index.d.cts +1 -1
  91. package/dist/machines/tree-view/index.d.mts +1 -1
  92. package/package.json +1 -1
@@ -5,7 +5,7 @@ import { t as TreeCollection } from "../../collection-DgzidRvr.mjs";
5
5
  import { a as createMachine, i as createGuards } from "../../core-Ci9Yu6QI.mjs";
6
6
  import "../../interact-outside-Ba50N1a5.mjs";
7
7
  import { n as trackDismissableElement } from "../../dismissable-B9k5K6f9.mjs";
8
- import { o as trackFocusVisible, t as getInteractionModality } from "../../focus-visible-BuLf8M9F.mjs";
8
+ import { a as setInteractionModality, o as trackFocusVisible, t as getInteractionModality } from "../../focus-visible-BuLf8M9F.mjs";
9
9
  import { n as getPlacement, t as getPlacementStyles } from "../../popper-BlgbmdAn.mjs";
10
10
  import { B as getRectCorners, D as closestSideToPoint, L as createPoint, R as createRect, i as isPointInPolygon } from "../../rect-utils-B5xqFvKC.mjs";
11
11
  import { t as createProps } from "../../create-props-DFW8DUsC.mjs";
@@ -69,7 +69,7 @@ function connect(service, normalize) {
69
69
  const disabled = prop("disabled") || context.get("fieldsetDisabled");
70
70
  const interactive = computed("isInteractive");
71
71
  const valueAsString = computed("valueAsString");
72
- const highlightedItem = context.get("highlightedItem");
72
+ const highlightedItems = context.get("highlightedItems");
73
73
  const selectedItems = context.get("selectedItems");
74
74
  const popperStyles = getPlacementStyles({
75
75
  ...prop("positioning"),
@@ -94,6 +94,7 @@ function connect(service, normalize) {
94
94
  };
95
95
  };
96
96
  const hasSelectedItems = value.length > 0;
97
+ const empty = value.length === 0;
97
98
  return {
98
99
  collection,
99
100
  open,
@@ -102,9 +103,10 @@ function connect(service, normalize) {
102
103
  disabled,
103
104
  value,
104
105
  highlightedValue,
105
- highlightedItem,
106
+ highlightedItems,
106
107
  selectedItems,
107
108
  hasSelectedItems,
109
+ empty,
108
110
  valueAsString,
109
111
  reposition(options = {}) {
110
112
  send({
@@ -119,12 +121,15 @@ function connect(service, normalize) {
119
121
  if (nextOpen === open) return;
120
122
  send({ type: nextOpen ? "OPEN" : "CLOSE" });
121
123
  },
122
- highlightValue(value) {
124
+ setHighlightValue(value) {
123
125
  send({
124
126
  type: "HIGHLIGHTED_VALUE.SET",
125
127
  value
126
128
  });
127
129
  },
130
+ clearHighlightValue() {
131
+ send({ type: "HIGHLIGHTED_VALUE.CLEAR" });
132
+ },
128
133
  setValue(value) {
129
134
  send({
130
135
  type: "VALUE.SET",
@@ -178,7 +183,7 @@ function connect(service, normalize) {
178
183
  dir: prop("dir"),
179
184
  id: dom.getControlId(scope),
180
185
  "data-disabled": dataAttr(disabled),
181
- "data-focused": dataAttr(focused),
186
+ "data-focus": dataAttr(focused),
182
187
  "data-readonly": dataAttr(prop("readOnly")),
183
188
  "data-invalid": dataAttr(prop("invalid")),
184
189
  "data-state": open ? "open" : "closed"
@@ -199,8 +204,9 @@ function connect(service, normalize) {
199
204
  "data-disabled": dataAttr(disabled),
200
205
  "data-readonly": dataAttr(prop("readOnly")),
201
206
  "data-invalid": dataAttr(prop("invalid")),
202
- "data-focused": dataAttr(focused),
207
+ "data-focus": dataAttr(focused),
203
208
  "data-placement": currentPlacement,
209
+ "data-placeholder-shown": dataAttr(!hasSelectedItems),
204
210
  disabled,
205
211
  onClick(event) {
206
212
  if (event.defaultPrevented) return;
@@ -448,6 +454,15 @@ function connect(service, normalize) {
448
454
  hidden: !itemState.selected
449
455
  });
450
456
  },
457
+ getValueTextProps() {
458
+ return normalize.element({
459
+ ...parts.valueText.attrs,
460
+ dir: prop("dir"),
461
+ "data-disabled": dataAttr(disabled),
462
+ "data-invalid": dataAttr(prop("invalid")),
463
+ "data-focus": dataAttr(focused)
464
+ });
465
+ },
451
466
  getHiddenInputProps() {
452
467
  const defaultValue = context.hash("value");
453
468
  return normalize.input({
@@ -575,7 +590,7 @@ const machine = createMachine({
575
590
  const value = prop("highlightedValue") ?? prop("defaultHighlightedValue") ?? null;
576
591
  return { defaultValue: value ? prop("collection").getIndexPath(value) : [] };
577
592
  }),
578
- highlightedItem: bindable(() => ({ defaultValue: null })),
593
+ highlightedItems: bindable(() => ({ defaultValue: [] })),
579
594
  selectedItems: bindable(() => ({ defaultValue: [] })),
580
595
  currentPlacement: bindable(() => ({ defaultValue: void 0 })),
581
596
  fieldsetDisabled: bindable(() => ({ defaultValue: false })),
@@ -615,6 +630,7 @@ const machine = createMachine({
615
630
  "VALUE.CLEAR": { actions: ["clearValue"] },
616
631
  "CLEAR_TRIGGER.CLICK": { actions: ["clearValue", "focusTriggerEl"] },
617
632
  "HIGHLIGHTED_VALUE.SET": { actions: ["setHighlightedValue"] },
633
+ "HIGHLIGHTED_VALUE.CLEAR": { actions: ["clearHighlightedValue"] },
618
634
  "ITEM.SELECT": { actions: ["selectItem"] },
619
635
  "ITEM.CLEAR": { actions: ["clearItem"] }
620
636
  },
@@ -901,8 +917,8 @@ const machine = createMachine({
901
917
  },
902
918
  shouldCloseOnSelectHighlighted: ({ prop, context }) => {
903
919
  const collection = prop("collection");
904
- const node = context.get("highlightedItem");
905
- return prop("closeOnSelect") && !collection.isBranchNode(node);
920
+ const node = last(context.get("highlightedItems"));
921
+ return prop("closeOnSelect") && node != null && !collection.isBranchNode(node);
906
922
  },
907
923
  canSelectItem: ({ prop, event }) => {
908
924
  const collection = prop("collection");
@@ -1014,7 +1030,7 @@ const machine = createMachine({
1014
1030
  const highlightedValue = context.get("highlightedValue");
1015
1031
  const highlightedIndexPath = context.get("highlightedIndexPath");
1016
1032
  if (!highlightedIndexPath.length) return;
1017
- if (getInteractionModality() !== "keyboard") return;
1033
+ if (getInteractionModality() === "pointer") return;
1018
1034
  dom.getListEls(scope).forEach((listEl, index) => {
1019
1035
  const itemPath = highlightedIndexPath.slice(0, index + 1);
1020
1036
  const itemEl = dom.getItemEl(scope, highlightedValue.toString());
@@ -1037,7 +1053,10 @@ const machine = createMachine({
1037
1053
  cleanups.push(raf_cleanup);
1038
1054
  });
1039
1055
  };
1040
- raf(() => exec(true));
1056
+ raf(() => {
1057
+ setInteractionModality("virtual");
1058
+ exec(true);
1059
+ });
1041
1060
  const rafCleanup = raf(() => exec(true));
1042
1061
  cleanups.push(rafCleanup);
1043
1062
  const observerCleanup = observeAttributes(dom.getContentEl(scope), {
@@ -1218,11 +1237,17 @@ const machine = createMachine({
1218
1237
  dom.getTriggerEl(scope)?.focus({ preventScroll: true });
1219
1238
  });
1220
1239
  },
1221
- invokeOnOpen({ prop }) {
1222
- prop("onOpenChange")?.({ open: true });
1240
+ invokeOnOpen({ prop, context }) {
1241
+ prop("onOpenChange")?.({
1242
+ open: true,
1243
+ value: context.get("value")
1244
+ });
1223
1245
  },
1224
- invokeOnClose({ prop }) {
1225
- prop("onOpenChange")?.({ open: false });
1246
+ invokeOnClose({ prop, context }) {
1247
+ prop("onOpenChange")?.({
1248
+ open: false,
1249
+ value: context.get("value")
1250
+ });
1226
1251
  },
1227
1252
  toggleVisibility({ send, prop }) {
1228
1253
  if (prop("open") != null) send({ type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE" });
@@ -1308,16 +1333,16 @@ const set = {
1308
1333
  highlightedValue({ context, prop }, value) {
1309
1334
  const collection = prop("collection");
1310
1335
  context.set("highlightedValue", value);
1311
- const highlightedIndexPath = value == null ? [] : collection.getIndexPath(value);
1336
+ const highlightedIndexPath = (value == null ? [] : collection.getIndexPath(value)) ?? [];
1312
1337
  context.set("highlightedIndexPath", highlightedIndexPath);
1313
- const highlightedItem = highlightedIndexPath.map((_, index) => {
1338
+ const highlightedItems = highlightedIndexPath.map((_, index) => {
1314
1339
  const partialPath = highlightedIndexPath.slice(0, index + 1);
1315
1340
  return collection.at(partialPath);
1316
1341
  });
1317
- context.set("highlightedItem", highlightedItem);
1342
+ context.set("highlightedItems", highlightedItems);
1318
1343
  prop("onHighlightChange")?.({
1319
- value,
1320
- items: highlightedItem
1344
+ highlightedValue: value,
1345
+ highlightedItems
1321
1346
  });
1322
1347
  }
1323
1348
  };
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-B24gMT
3
3
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
4
4
 
5
5
  //#region src/machines/checkbox/checkbox.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "indicator" | "label" | "control">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "indicator">;
7
7
  //#endregion
8
8
  //#region src/machines/checkbox/checkbox.types.d.ts
9
9
  type CheckedState = boolean | "indeterminate";
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DUM9rz
3
3
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
4
4
 
5
5
  //#region src/machines/checkbox/checkbox.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "indicator" | "label" | "control">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "indicator">;
7
7
  //#endregion
8
8
  //#region src/machines/checkbox/checkbox.types.d.ts
9
9
  type CheckedState = boolean | "indeterminate";
@@ -3,7 +3,7 @@ import { p as Machine, y as Service } from "../../types-B24gMTKq.cjs";
3
3
  import { b as NormalizeProps, g as RequiredBy, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
4
4
 
5
5
  //#region src/machines/clipboard/clipboard.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "indicator" | "label" | "control" | "input" | "trigger">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "input" | "indicator" | "trigger">;
7
7
  //#endregion
8
8
  //#region src/machines/clipboard/clipboard.types.d.ts
9
9
  interface CopyStatusDetails {
@@ -3,7 +3,7 @@ import { p as Machine, y as Service } from "../../types-DUM9rzfD.mjs";
3
3
  import { b as NormalizeProps, g as RequiredBy, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
4
4
 
5
5
  //#region src/machines/clipboard/clipboard.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "indicator" | "label" | "control" | "input" | "trigger">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "input" | "indicator" | "trigger">;
7
7
  //#endregion
8
8
  //#region src/machines/clipboard/clipboard.types.d.ts
9
9
  interface CopyStatusDetails {
@@ -3,7 +3,7 @@ import { p as Machine, y as Service } from "../../types-B24gMTKq.cjs";
3
3
  import { b as NormalizeProps, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
4
4
 
5
5
  //#region src/machines/collapsible/collapsible.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "indicator" | "content" | "trigger">;
6
+ declare const anatomy: AnatomyInstance<"root" | "content" | "indicator" | "trigger">;
7
7
  //#endregion
8
8
  //#region src/machines/collapsible/collapsible.types.d.ts
9
9
  interface OpenChangeDetails {
@@ -3,7 +3,7 @@ import { p as Machine, y as Service } from "../../types-DUM9rzfD.mjs";
3
3
  import { b as NormalizeProps, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
4
4
 
5
5
  //#region src/machines/collapsible/collapsible.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "indicator" | "content" | "trigger">;
6
+ declare const anatomy: AnatomyInstance<"root" | "content" | "indicator" | "trigger">;
7
7
  //#endregion
8
8
  //#region src/machines/collapsible/collapsible.types.d.ts
9
9
  interface OpenChangeDetails {
@@ -6,7 +6,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
6
6
  import { d as PositioningOptions } from "../../types-CZAtqGqH.cjs";
7
7
 
8
8
  //#region src/machines/color-picker/color-picker.anatomy.d.ts
9
- declare const anatomy: Anatomy<"root" | "label" | "control" | "content" | "trigger" | "area" | "valueText" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
9
+ declare const anatomy: Anatomy<"root" | "label" | "valueText" | "control" | "area" | "content" | "trigger" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
10
10
  //#endregion
11
11
  //#region src/machines/color-picker/color-picker.types.d.ts
12
12
  type ExtendedColorChannel = ColorChannel | "hex" | "css";
@@ -6,7 +6,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
6
6
  import { p as PositioningOptions } from "../../index-fMh0VDkR.mjs";
7
7
 
8
8
  //#region src/machines/color-picker/color-picker.anatomy.d.ts
9
- declare const anatomy: Anatomy<"root" | "label" | "control" | "content" | "trigger" | "area" | "valueText" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
9
+ declare const anatomy: Anatomy<"root" | "label" | "valueText" | "control" | "area" | "content" | "trigger" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
10
10
  //#endregion
11
11
  //#region src/machines/color-picker/color-picker.types.d.ts
12
12
  type ExtendedColorChannel = ColorChannel | "hex" | "css";
@@ -46,8 +46,8 @@ const getItemEl = (ctx, value) => {
46
46
  };
47
47
  const focusInputEl = (ctx) => {
48
48
  const inputEl = getInputEl(ctx);
49
- if (ctx.isActiveElement(inputEl)) return;
50
- inputEl?.focus({ preventScroll: true });
49
+ if (!ctx.isActiveElement(inputEl)) inputEl?.focus({ preventScroll: true });
50
+ require_dom_query.setCaretToEnd(inputEl);
51
51
  };
52
52
  const focusTriggerEl = (ctx) => {
53
53
  const triggerEl = getTriggerEl(ctx);
@@ -74,12 +74,12 @@ function connect(service, normalize) {
74
74
  placement: context.get("currentPlacement")
75
75
  });
76
76
  function getItemState(props) {
77
- const disabled = collection.getItemDisabled(props.item);
77
+ const itemDisabled = collection.getItemDisabled(props.item);
78
78
  const value = collection.getItemValue(props.item);
79
79
  require_utils.ensure(value, () => `[sprawlify-js] No value found for item ${JSON.stringify(props.item)}`);
80
80
  return {
81
81
  value,
82
- disabled: Boolean(disabled || disabled),
82
+ disabled: Boolean(disabled || itemDisabled),
83
83
  highlighted: highlightedValue === value,
84
84
  selected: context.get("value").includes(value)
85
85
  };
@@ -359,7 +359,7 @@ function connect(service, normalize) {
359
359
  if (!require_dom_query.isLeftClick(event)) return;
360
360
  event.preventDefault();
361
361
  queueMicrotask(() => {
362
- getInputEl(scope)?.focus({ preventScroll: true });
362
+ focusInputEl(scope);
363
363
  });
364
364
  },
365
365
  onKeyDown(event) {
@@ -581,7 +581,7 @@ const machine = createMachine({
581
581
  const context = getContext();
582
582
  const prevSelectedItems = context.get("selectedItems");
583
583
  const collection = prop("collection");
584
- const nextItems = value.map((v) => {
584
+ const nextItems = (prop("value") || value).map((v) => {
585
585
  return prevSelectedItems.find((item) => collection.getItemValue(item) === v) || collection.find(v);
586
586
  });
587
587
  context.set("selectedItems", nextItems);
@@ -799,8 +799,7 @@ const machine = createMachine({
799
799
  ],
800
800
  "INPUT.ARROW_UP": [
801
801
  {
802
- guard: "autoComplete",
803
- target: "interacting",
802
+ guard: and("isOpenControlled", "autoComplete"),
804
803
  actions: ["invokeOnOpen"]
805
804
  },
806
805
  {
@@ -809,7 +808,7 @@ const machine = createMachine({
809
808
  actions: ["invokeOnOpen"]
810
809
  },
811
810
  {
812
- target: "interacting",
811
+ guard: "isOpenControlled",
813
812
  actions: ["highlightLastOrSelectedItem", "invokeOnOpen"]
814
813
  },
815
814
  {
@@ -1205,7 +1204,7 @@ const machine = createMachine({
1205
1204
  const inputEl = getInputEl(scope);
1206
1205
  let cleanups = [];
1207
1206
  const exec = (immediate) => {
1208
- if (require_focus_visible.getInteractionModality() !== "keyboard") return;
1207
+ if (require_focus_visible.getInteractionModality() === "pointer") return;
1209
1208
  const highlightedValue = context.get("highlightedValue");
1210
1209
  if (!highlightedValue) return;
1211
1210
  const contentEl = getContentEl(scope);
@@ -1227,7 +1226,10 @@ const machine = createMachine({
1227
1226
  });
1228
1227
  cleanups.push(raf_cleanup);
1229
1228
  };
1230
- const rafCleanup = require_dom_query.raf(() => exec(true));
1229
+ const rafCleanup = require_dom_query.raf(() => {
1230
+ require_focus_visible.setInteractionModality("virtual");
1231
+ exec(true);
1232
+ });
1231
1233
  cleanups.push(rafCleanup);
1232
1234
  const observerCleanup = require_dom_query.observeAttributes(inputEl, {
1233
1235
  attributes: ["aria-activedescendant"],
@@ -7,7 +7,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
7
7
  import { c as Placement, d as PositioningOptions } from "../../types-CZAtqGqH.cjs";
8
8
 
9
9
  //#region src/machines/combobox/combobox.anatomy.d.ts
10
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "content" | "item" | "itemIndicator" | "input" | "itemText" | "trigger" | "itemGroup" | "clearTrigger" | "positioner" | "list" | "itemGroupLabel">;
10
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "input" | "clearTrigger" | "content" | "item" | "itemText" | "trigger" | "positioner" | "list" | "itemIndicator" | "itemGroup" | "itemGroupLabel">;
11
11
  //#endregion
12
12
  //#region src/machines/combobox/combobox.collection.d.ts
13
13
  declare const collection: {
@@ -7,7 +7,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
7
7
  import { p as PositioningOptions, u as Placement } from "../../index-fMh0VDkR.mjs";
8
8
 
9
9
  //#region src/machines/combobox/combobox.anatomy.d.ts
10
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "content" | "item" | "itemIndicator" | "input" | "itemText" | "trigger" | "itemGroup" | "clearTrigger" | "positioner" | "list" | "itemGroupLabel">;
10
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "input" | "clearTrigger" | "content" | "item" | "itemText" | "trigger" | "positioner" | "list" | "itemIndicator" | "itemGroup" | "itemGroupLabel">;
11
11
  //#endregion
12
12
  //#region src/machines/combobox/combobox.collection.d.ts
13
13
  declare const collection: {
@@ -5,7 +5,7 @@ import { s as ListCollection } from "../../collection-DgzidRvr.mjs";
5
5
  import { o as setup } from "../../core-Ci9Yu6QI.mjs";
6
6
  import "../../interact-outside-Ba50N1a5.mjs";
7
7
  import { n as trackDismissableElement } from "../../dismissable-B9k5K6f9.mjs";
8
- import { o as trackFocusVisible, t as getInteractionModality } from "../../focus-visible-BuLf8M9F.mjs";
8
+ import { a as setInteractionModality, o as trackFocusVisible, t as getInteractionModality } from "../../focus-visible-BuLf8M9F.mjs";
9
9
  import { n as getPlacement, t as getPlacementStyles } from "../../popper-BlgbmdAn.mjs";
10
10
  import { t as createProps } from "../../create-props-DFW8DUsC.mjs";
11
11
  //#region src/machines/combobox/combobox.anatomy.ts
@@ -45,8 +45,8 @@ const getItemEl = (ctx, value) => {
45
45
  };
46
46
  const focusInputEl = (ctx) => {
47
47
  const inputEl = getInputEl(ctx);
48
- if (ctx.isActiveElement(inputEl)) return;
49
- inputEl?.focus({ preventScroll: true });
48
+ if (!ctx.isActiveElement(inputEl)) inputEl?.focus({ preventScroll: true });
49
+ setCaretToEnd(inputEl);
50
50
  };
51
51
  const focusTriggerEl = (ctx) => {
52
52
  const triggerEl = getTriggerEl(ctx);
@@ -73,12 +73,12 @@ function connect(service, normalize) {
73
73
  placement: context.get("currentPlacement")
74
74
  });
75
75
  function getItemState(props) {
76
- const disabled = collection.getItemDisabled(props.item);
76
+ const itemDisabled = collection.getItemDisabled(props.item);
77
77
  const value = collection.getItemValue(props.item);
78
78
  ensure(value, () => `[sprawlify-js] No value found for item ${JSON.stringify(props.item)}`);
79
79
  return {
80
80
  value,
81
- disabled: Boolean(disabled || disabled),
81
+ disabled: Boolean(disabled || itemDisabled),
82
82
  highlighted: highlightedValue === value,
83
83
  selected: context.get("value").includes(value)
84
84
  };
@@ -358,7 +358,7 @@ function connect(service, normalize) {
358
358
  if (!isLeftClick(event)) return;
359
359
  event.preventDefault();
360
360
  queueMicrotask(() => {
361
- getInputEl(scope)?.focus({ preventScroll: true });
361
+ focusInputEl(scope);
362
362
  });
363
363
  },
364
364
  onKeyDown(event) {
@@ -580,7 +580,7 @@ const machine = createMachine({
580
580
  const context = getContext();
581
581
  const prevSelectedItems = context.get("selectedItems");
582
582
  const collection = prop("collection");
583
- const nextItems = value.map((v) => {
583
+ const nextItems = (prop("value") || value).map((v) => {
584
584
  return prevSelectedItems.find((item) => collection.getItemValue(item) === v) || collection.find(v);
585
585
  });
586
586
  context.set("selectedItems", nextItems);
@@ -798,8 +798,7 @@ const machine = createMachine({
798
798
  ],
799
799
  "INPUT.ARROW_UP": [
800
800
  {
801
- guard: "autoComplete",
802
- target: "interacting",
801
+ guard: and("isOpenControlled", "autoComplete"),
803
802
  actions: ["invokeOnOpen"]
804
803
  },
805
804
  {
@@ -808,7 +807,7 @@ const machine = createMachine({
808
807
  actions: ["invokeOnOpen"]
809
808
  },
810
809
  {
811
- target: "interacting",
810
+ guard: "isOpenControlled",
812
811
  actions: ["highlightLastOrSelectedItem", "invokeOnOpen"]
813
812
  },
814
813
  {
@@ -1204,7 +1203,7 @@ const machine = createMachine({
1204
1203
  const inputEl = getInputEl(scope);
1205
1204
  let cleanups = [];
1206
1205
  const exec = (immediate) => {
1207
- if (getInteractionModality() !== "keyboard") return;
1206
+ if (getInteractionModality() === "pointer") return;
1208
1207
  const highlightedValue = context.get("highlightedValue");
1209
1208
  if (!highlightedValue) return;
1210
1209
  const contentEl = getContentEl(scope);
@@ -1226,7 +1225,10 @@ const machine = createMachine({
1226
1225
  });
1227
1226
  cleanups.push(raf_cleanup);
1228
1227
  };
1229
- const rafCleanup = raf(() => exec(true));
1228
+ const rafCleanup = raf(() => {
1229
+ setInteractionModality("virtual");
1230
+ exec(true);
1231
+ });
1230
1232
  cleanups.push(rafCleanup);
1231
1233
  const observerCleanup = observeAttributes(inputEl, {
1232
1234
  attributes: ["aria-activedescendant"],