@sprawlify/primitives 0.1.10 → 0.1.12

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 (107) hide show
  1. package/dist/{collection-BBgC8xCb.cjs → collection-D0Abtxc0.cjs} +68 -0
  2. package/dist/{collection-DgzidRvr.mjs → collection-GSpaYJ2f.mjs} +45 -1
  3. package/dist/collection.cjs +5 -1
  4. package/dist/collection.d.cts +49 -3
  5. package/dist/collection.d.mts +49 -3
  6. package/dist/collection.mjs +2 -2
  7. package/dist/{focus-trap-BewqTQFt.cjs → focus-trap-BbU9QXMe.cjs} +1 -1
  8. package/dist/{focus-trap-Do8IUXYh.mjs → focus-trap-CzhQ01j4.mjs} +1 -1
  9. package/dist/focus-trap.cjs +1 -1
  10. package/dist/focus-trap.mjs +1 -1
  11. package/dist/{list-collection-B_8BN0XB.d.cts → list-collection-Cjgbx_9l.d.cts} +1 -1
  12. package/dist/{list-collection-DkRA5LOq.d.mts → list-collection-IF510iNl.d.mts} +1 -1
  13. package/dist/machines/accordion/index.d.cts +1 -1
  14. package/dist/machines/accordion/index.d.mts +1 -1
  15. package/dist/machines/angle-slider/index.d.cts +1 -1
  16. package/dist/machines/angle-slider/index.d.mts +1 -1
  17. package/dist/machines/cascade-select/index.cjs +1 -1
  18. package/dist/machines/cascade-select/index.d.cts +2 -2
  19. package/dist/machines/cascade-select/index.d.mts +2 -2
  20. package/dist/machines/cascade-select/index.mjs +1 -1
  21. package/dist/machines/clipboard/index.d.cts +1 -1
  22. package/dist/machines/clipboard/index.d.mts +1 -1
  23. package/dist/machines/collapsible/index.d.cts +1 -1
  24. package/dist/machines/collapsible/index.d.mts +1 -1
  25. package/dist/machines/color-picker/index.d.cts +1 -1
  26. package/dist/machines/color-picker/index.d.mts +1 -1
  27. package/dist/machines/combobox/index.cjs +279 -355
  28. package/dist/machines/combobox/index.d.cts +5 -4
  29. package/dist/machines/combobox/index.d.mts +5 -4
  30. package/dist/machines/combobox/index.mjs +279 -355
  31. package/dist/machines/date-input/index.cjs +1830 -0
  32. package/dist/machines/date-input/index.d.cts +223 -0
  33. package/dist/machines/date-input/index.d.mts +223 -0
  34. package/dist/machines/date-input/index.mjs +1813 -0
  35. package/dist/machines/date-picker/index.d.cts +1 -1
  36. package/dist/machines/date-picker/index.d.mts +1 -1
  37. package/dist/machines/dialog/index.cjs +1 -1
  38. package/dist/machines/dialog/index.d.cts +1 -1
  39. package/dist/machines/dialog/index.d.mts +1 -1
  40. package/dist/machines/dialog/index.mjs +1 -1
  41. package/dist/machines/drawer/index.cjs +1 -1
  42. package/dist/machines/drawer/index.d.cts +1 -1
  43. package/dist/machines/drawer/index.d.mts +1 -1
  44. package/dist/machines/drawer/index.mjs +1 -1
  45. package/dist/machines/dropdown-menu/index.d.cts +1 -1
  46. package/dist/machines/dropdown-menu/index.d.mts +1 -1
  47. package/dist/machines/editable/index.d.cts +1 -1
  48. package/dist/machines/editable/index.d.mts +1 -1
  49. package/dist/machines/file-upload/index.d.cts +1 -1
  50. package/dist/machines/file-upload/index.d.mts +1 -1
  51. package/dist/machines/floating-panel/index.d.cts +1 -1
  52. package/dist/machines/floating-panel/index.d.mts +1 -1
  53. package/dist/machines/hover-card/index.d.cts +1 -1
  54. package/dist/machines/hover-card/index.d.mts +1 -1
  55. package/dist/machines/listbox/index.cjs +41 -16
  56. package/dist/machines/listbox/index.d.cts +5 -4
  57. package/dist/machines/listbox/index.d.mts +5 -4
  58. package/dist/machines/listbox/index.mjs +42 -17
  59. package/dist/machines/marquee/index.d.cts +2 -2
  60. package/dist/machines/marquee/index.d.mts +2 -2
  61. package/dist/machines/navigation-menu/index.d.cts +1 -1
  62. package/dist/machines/navigation-menu/index.d.mts +1 -1
  63. package/dist/machines/number-input/index.d.cts +1 -1
  64. package/dist/machines/number-input/index.d.mts +1 -1
  65. package/dist/machines/password-input/index.d.cts +1 -1
  66. package/dist/machines/password-input/index.d.mts +1 -1
  67. package/dist/machines/pin-input/index.d.cts +1 -1
  68. package/dist/machines/pin-input/index.d.mts +1 -1
  69. package/dist/machines/popover/index.cjs +1 -1
  70. package/dist/machines/popover/index.d.cts +1 -1
  71. package/dist/machines/popover/index.d.mts +1 -1
  72. package/dist/machines/popover/index.mjs +1 -1
  73. package/dist/machines/progress/index.d.cts +1 -1
  74. package/dist/machines/progress/index.d.mts +1 -1
  75. package/dist/machines/select/index.cjs +47 -18
  76. package/dist/machines/select/index.d.cts +4 -3
  77. package/dist/machines/select/index.d.mts +4 -3
  78. package/dist/machines/select/index.mjs +48 -19
  79. package/dist/machines/signature-pad/index.d.cts +1 -1
  80. package/dist/machines/signature-pad/index.d.mts +1 -1
  81. package/dist/machines/slider/index.d.cts +1 -1
  82. package/dist/machines/slider/index.d.mts +1 -1
  83. package/dist/machines/steps/index.d.cts +1 -1
  84. package/dist/machines/steps/index.d.mts +1 -1
  85. package/dist/machines/switch/index.d.cts +1 -1
  86. package/dist/machines/switch/index.d.mts +1 -1
  87. package/dist/machines/tabs/index.d.cts +1 -1
  88. package/dist/machines/tabs/index.d.mts +1 -1
  89. package/dist/machines/tags-input/index.d.cts +1 -1
  90. package/dist/machines/tags-input/index.d.mts +1 -1
  91. package/dist/machines/timer/index.d.cts +1 -1
  92. package/dist/machines/timer/index.d.mts +1 -1
  93. package/dist/machines/toast/index.d.cts +1 -1
  94. package/dist/machines/toast/index.d.mts +1 -1
  95. package/dist/machines/tooltip/index.d.cts +1 -1
  96. package/dist/machines/tooltip/index.d.mts +1 -1
  97. package/dist/machines/tour/index.cjs +1 -1
  98. package/dist/machines/tour/index.d.cts +1 -1
  99. package/dist/machines/tour/index.d.mts +1 -1
  100. package/dist/machines/tour/index.mjs +1 -1
  101. package/dist/machines/tree-view/index.cjs +1 -1
  102. package/dist/machines/tree-view/index.d.cts +1 -1
  103. package/dist/machines/tree-view/index.d.mts +1 -1
  104. package/dist/machines/tree-view/index.mjs +1 -1
  105. package/dist/{selection-DdNvrKbj.d.mts → selection-6urf-c8j.d.mts} +1 -1
  106. package/dist/{selection-Bb_ZSVxe.d.cts → selection-BmS2RDMq.d.cts} +1 -1
  107. package/package.json +13 -1
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
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/password-input/password-input.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "input" | "label" | "control" | "indicator" | "visibilityTrigger">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "indicator" | "input" | "visibilityTrigger">;
7
7
  //#endregion
8
8
  //#region src/machines/password-input/password-input.types.d.ts
9
9
  interface VisibilityChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
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/password-input/password-input.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "input" | "label" | "control" | "indicator" | "visibilityTrigger">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "indicator" | "input" | "visibilityTrigger">;
7
7
  //#endregion
8
8
  //#region src/machines/password-input/password-input.types.d.ts
9
9
  interface VisibilityChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
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/pin-input/pin-input.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "input" | "label" | "control">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "input">;
7
7
  //#endregion
8
8
  //#region src/machines/pin-input/pin-input.types.d.ts
9
9
  interface ValueChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
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/pin-input/pin-input.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "input" | "label" | "control">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "input">;
7
7
  //#endregion
8
8
  //#region src/machines/pin-input/pin-input.types.d.ts
9
9
  interface ValueChangeDetails {
@@ -6,7 +6,7 @@ const require_utils = require("../../utils-ByNiZU8f.cjs");
6
6
  const require_core = require("../../core-Bw_czdwX.cjs");
7
7
  require("../../interact-outside-Bg-QSXqp.cjs");
8
8
  const require_dismissable = require("../../dismissable-DxjbwsOf.cjs");
9
- const require_focus_trap = require("../../focus-trap-BewqTQFt.cjs");
9
+ const require_focus_trap = require("../../focus-trap-BbU9QXMe.cjs");
10
10
  const require_popper = require("../../popper-viCrafLC.cjs");
11
11
  const require_create_props = require("../../create-props-DP39rHnH.cjs");
12
12
  const require_remove_scroll = require("../../remove-scroll-D4CMJmU2.cjs");
@@ -6,7 +6,7 @@ import { r as PersistentElementOptions, t as DismissableElementHandlers } from "
6
6
  import { c as Placement, d as PositioningOptions } from "../../types-CZAtqGqH.cjs";
7
7
 
8
8
  //#region src/machines/popover/popover.anatomy.d.ts
9
- declare const anatomy: AnatomyInstance<"trigger" | "indicator" | "content" | "title" | "positioner" | "arrow" | "description" | "closeTrigger" | "anchor" | "arrowTip">;
9
+ declare const anatomy: AnatomyInstance<"content" | "trigger" | "indicator" | "title" | "description" | "closeTrigger" | "arrow" | "arrowTip" | "positioner" | "anchor">;
10
10
  //#endregion
11
11
  //#region src/machines/popover/popover.types.d.ts
12
12
  interface OpenChangeDetails {
@@ -6,7 +6,7 @@ import { r as PersistentElementOptions, t as DismissableElementHandlers } from "
6
6
  import { p as PositioningOptions, u as Placement } from "../../index-fMh0VDkR.mjs";
7
7
 
8
8
  //#region src/machines/popover/popover.anatomy.d.ts
9
- declare const anatomy: AnatomyInstance<"trigger" | "indicator" | "content" | "title" | "positioner" | "arrow" | "description" | "closeTrigger" | "anchor" | "arrowTip">;
9
+ declare const anatomy: AnatomyInstance<"content" | "trigger" | "indicator" | "title" | "description" | "closeTrigger" | "arrow" | "arrowTip" | "positioner" | "anchor">;
10
10
  //#endregion
11
11
  //#region src/machines/popover/popover.types.d.ts
12
12
  interface OpenChangeDetails {
@@ -5,7 +5,7 @@ import { u as createSplitProps } from "../../utils-VVoZ_v29.mjs";
5
5
  import { a as createMachine } from "../../core-CTtbW9qh.mjs";
6
6
  import "../../interact-outside-Ba50N1a5.mjs";
7
7
  import { n as trackDismissableElement } from "../../dismissable-B9k5K6f9.mjs";
8
- import { t as trapFocus } from "../../focus-trap-Do8IUXYh.mjs";
8
+ import { t as trapFocus } from "../../focus-trap-CzhQ01j4.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
  import { t as preventBodyScroll } from "../../remove-scroll-D55GZoBb.mjs";
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
3
3
  import { b as NormalizeProps, d as Orientation, f as OrientationProperty, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
4
4
 
5
5
  //#region src/machines/progress/progress.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "label" | "track" | "circle" | "view" | "valueText" | "range" | "circleTrack" | "circleRange">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "valueText" | "track" | "circle" | "view" | "range" | "circleTrack" | "circleRange">;
7
7
  //#endregion
8
8
  //#region src/machines/progress/progress.types.d.ts
9
9
  type ProgressState = "indeterminate" | "loading" | "complete";
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
3
3
  import { b as NormalizeProps, d as Orientation, f as OrientationProperty, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
4
4
 
5
5
  //#region src/machines/progress/progress.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "label" | "track" | "circle" | "view" | "valueText" | "range" | "circleTrack" | "circleRange">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "valueText" | "track" | "circle" | "view" | "range" | "circleTrack" | "circleRange">;
7
7
  //#endregion
8
8
  //#region src/machines/progress/progress.types.d.ts
9
9
  type ProgressState = "indeterminate" | "loading" | "complete";
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_create_anatomy = require("../../create-anatomy-BnwEmNnc.cjs");
3
3
  const require_dom_query = require("../../dom-query-BUO7rGsg.cjs");
4
4
  const require_utils = require("../../utils-ByNiZU8f.cjs");
5
- const require_collection = require("../../collection-BBgC8xCb.cjs");
5
+ const require_collection = require("../../collection-D0Abtxc0.cjs");
6
6
  const require_core = require("../../core-Bw_czdwX.cjs");
7
7
  require("../../interact-outside-Bg-QSXqp.cjs");
8
8
  const require_dismissable = require("../../dismissable-DxjbwsOf.cjs");
@@ -56,7 +56,7 @@ function connect(service, normalize) {
56
56
  const focused = state.matches("focused");
57
57
  const highlightedValue = context.get("highlightedValue");
58
58
  const highlightedItem = context.get("highlightedItem");
59
- const selectedItems = context.get("selectedItems");
59
+ const selectedItems = computed("selectedItems");
60
60
  const currentPlacement = context.get("currentPlacement");
61
61
  const isTypingAhead = computed("isTypingAhead");
62
62
  const interactive = computed("isInteractive");
@@ -508,17 +508,32 @@ const machine = require_core.createMachine({
508
508
  }
509
509
  };
510
510
  },
511
- context({ prop, bindable }) {
511
+ context({ prop, bindable, getContext }) {
512
+ const initialValue = prop("value") ?? prop("defaultValue") ?? [];
513
+ const initialSelectedItems = prop("collection").findMany(initialValue);
512
514
  return {
513
515
  value: bindable(() => ({
514
516
  defaultValue: prop("defaultValue"),
515
517
  value: prop("value"),
516
518
  isEqual: require_utils.isEqual,
517
519
  onChange(value) {
518
- const items = prop("collection").findMany(value);
520
+ const context = getContext();
521
+ const collection = prop("collection");
522
+ const proposed = require_collection.deriveSelectionState({
523
+ values: value,
524
+ collection,
525
+ selectedItemMap: context.get("selectedItemMap")
526
+ });
527
+ const effectiveValue = prop("value") ?? value;
528
+ const effective = effectiveValue === value ? proposed : require_collection.deriveSelectionState({
529
+ values: effectiveValue,
530
+ collection,
531
+ selectedItemMap: proposed.nextSelectedItemMap
532
+ });
533
+ context.set("selectedItemMap", effective.nextSelectedItemMap);
519
534
  return prop("onValueChange")?.({
520
535
  value,
521
- items
536
+ items: proposed.selectedItems
522
537
  });
523
538
  }
524
539
  })),
@@ -536,9 +551,11 @@ const machine = require_core.createMachine({
536
551
  currentPlacement: bindable(() => ({ defaultValue: void 0 })),
537
552
  fieldsetDisabled: bindable(() => ({ defaultValue: false })),
538
553
  highlightedItem: bindable(() => ({ defaultValue: null })),
539
- selectedItems: bindable(() => {
540
- const value = prop("value") ?? prop("defaultValue") ?? [];
541
- return { defaultValue: prop("collection").findMany(value) };
554
+ selectedItemMap: bindable(() => {
555
+ return { defaultValue: require_collection.createSelectedItemMap({
556
+ selectedItems: initialSelectedItems,
557
+ collection: prop("collection")
558
+ }) };
542
559
  })
543
560
  };
544
561
  },
@@ -550,7 +567,12 @@ const machine = require_core.createMachine({
550
567
  isTypingAhead: ({ refs }) => refs.get("typeahead").keysSoFar !== "",
551
568
  isDisabled: ({ prop, context }) => !!prop("disabled") || !!context.get("fieldsetDisabled"),
552
569
  isInteractive: ({ prop }) => !(prop("disabled") || prop("readOnly")),
553
- valueAsString: ({ context, prop }) => prop("collection").stringifyItems(context.get("selectedItems"))
570
+ selectedItems: ({ context, prop }) => require_collection.resolveSelectedItems({
571
+ values: context.get("value"),
572
+ collection: prop("collection"),
573
+ selectedItemMap: context.get("selectedItemMap")
574
+ }),
575
+ valueAsString: ({ computed, prop }) => prop("collection").stringifyItems(computed("selectedItems"))
554
576
  },
555
577
  initialState({ prop }) {
556
578
  return prop("open") || prop("defaultOpen") ? "open" : "idle";
@@ -883,7 +905,7 @@ const machine = require_core.createMachine({
883
905
  const exec = (immediate) => {
884
906
  const highlightedValue = context.get("highlightedValue");
885
907
  if (highlightedValue == null) return;
886
- if (require_focus_visible.getInteractionModality() !== "keyboard") return;
908
+ if (require_focus_visible.getInteractionModality() === "pointer") return;
887
909
  const contentEl = getContentEl(scope);
888
910
  const scrollToIndexFn = prop("scrollToIndexFn");
889
911
  if (scrollToIndexFn) {
@@ -900,7 +922,10 @@ const machine = require_core.createMachine({
900
922
  block: "nearest"
901
923
  });
902
924
  };
903
- require_dom_query.raf(() => exec(true));
925
+ require_dom_query.raf(() => {
926
+ require_focus_visible.setInteractionModality("virtual");
927
+ exec(true);
928
+ });
904
929
  const contentEl = () => getContentEl(scope);
905
930
  return require_dom_query.observeAttributes(contentEl, {
906
931
  defer: true,
@@ -1085,16 +1110,20 @@ const machine = require_core.createMachine({
1085
1110
  const collection = prop("collection");
1086
1111
  const highlightedItem = collection.find(context.get("highlightedValue"));
1087
1112
  if (highlightedItem) context.set("highlightedItem", highlightedItem);
1088
- const selectedItems = collection.findMany(context.get("value"));
1089
- context.set("selectedItems", selectedItems);
1113
+ const next = require_collection.deriveSelectionState({
1114
+ values: context.get("value"),
1115
+ collection,
1116
+ selectedItemMap: context.get("selectedItemMap")
1117
+ });
1118
+ context.set("selectedItemMap", next.nextSelectedItemMap);
1090
1119
  },
1091
1120
  syncSelectedItems({ context, prop }) {
1092
- const collection = prop("collection");
1093
- const prevSelectedItems = context.get("selectedItems");
1094
- const selectedItems = context.get("value").map((value) => {
1095
- return prevSelectedItems.find((item) => collection.getItemValue(item) === value) || collection.find(value);
1121
+ const next = require_collection.deriveSelectionState({
1122
+ values: context.get("value"),
1123
+ collection: prop("collection"),
1124
+ selectedItemMap: context.get("selectedItemMap")
1096
1125
  });
1097
- context.set("selectedItems", selectedItems);
1126
+ context.set("selectedItemMap", next.nextSelectedItemMap);
1098
1127
  },
1099
1128
  syncHighlightedItem({ context, prop }) {
1100
1129
  const collection = prop("collection");
@@ -1,6 +1,6 @@
1
1
  import { n as AnatomyInstance } from "../../create-anatomy-9eFQs7lO.cjs";
2
2
  import { r as CollectionOptions, t as CollectionItem } from "../../types-D-7AMgSE.cjs";
3
- import { t as ListCollection } from "../../list-collection-B_8BN0XB.cjs";
3
+ import { t as ListCollection } from "../../list-collection-Cjgbx_9l.cjs";
4
4
  import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCSDE.cjs";
5
5
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
6
6
  import { n as TypeaheadState } from "../../typeahead-DMooWbbX.cjs";
@@ -8,7 +8,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
8
8
  import { c as Placement, d as PositioningOptions } from "../../types-CZAtqGqH.cjs";
9
9
 
10
10
  //#region src/machines/select/select.anatomy.d.ts
11
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "trigger" | "indicator" | "content" | "item" | "itemIndicator" | "itemGroup" | "valueText" | "itemText" | "clearTrigger" | "positioner" | "list" | "itemGroupLabel">;
11
+ declare const anatomy: AnatomyInstance<"root" | "content" | "label" | "valueText" | "control" | "trigger" | "indicator" | "item" | "itemIndicator" | "itemText" | "list" | "positioner" | "itemGroup" | "itemGroupLabel" | "clearTrigger">;
12
12
  //#endregion
13
13
  //#region src/machines/select/select.collection.d.ts
14
14
  declare const collection: {
@@ -89,13 +89,14 @@ interface SelectSchema<T extends CollectionItem = CollectionItem> {
89
89
  highlightedValue: string | null;
90
90
  fieldsetDisabled: boolean;
91
91
  highlightedItem: T | null;
92
- selectedItems: T[];
92
+ selectedItemMap: Map<string, T>;
93
93
  };
94
94
  computed: {
95
95
  hasSelectedItems: boolean;
96
96
  isTypingAhead: boolean;
97
97
  isInteractive: boolean;
98
98
  isDisabled: boolean;
99
+ selectedItems: T[];
99
100
  valueAsString: string;
100
101
  };
101
102
  refs: {
@@ -1,6 +1,6 @@
1
1
  import { n as AnatomyInstance } from "../../create-anatomy-BedZVdg0.mjs";
2
2
  import { r as CollectionOptions, t as CollectionItem } from "../../types-9uw8LHpE.mjs";
3
- import { t as ListCollection } from "../../list-collection-DkRA5LOq.mjs";
3
+ import { t as ListCollection } from "../../list-collection-IF510iNl.mjs";
4
4
  import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCWsb.mjs";
5
5
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
6
6
  import { n as TypeaheadState } from "../../typeahead-Bbeb1fAR.mjs";
@@ -8,7 +8,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
8
8
  import { p as PositioningOptions, u as Placement } from "../../index-fMh0VDkR.mjs";
9
9
 
10
10
  //#region src/machines/select/select.anatomy.d.ts
11
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "trigger" | "indicator" | "content" | "item" | "itemIndicator" | "itemGroup" | "valueText" | "itemText" | "clearTrigger" | "positioner" | "list" | "itemGroupLabel">;
11
+ declare const anatomy: AnatomyInstance<"root" | "content" | "label" | "valueText" | "control" | "trigger" | "indicator" | "item" | "itemIndicator" | "itemText" | "list" | "positioner" | "itemGroup" | "itemGroupLabel" | "clearTrigger">;
12
12
  //#endregion
13
13
  //#region src/machines/select/select.collection.d.ts
14
14
  declare const collection: {
@@ -89,13 +89,14 @@ interface SelectSchema<T extends CollectionItem = CollectionItem> {
89
89
  highlightedValue: string | null;
90
90
  fieldsetDisabled: boolean;
91
91
  highlightedItem: T | null;
92
- selectedItems: T[];
92
+ selectedItemMap: Map<string, T>;
93
93
  };
94
94
  computed: {
95
95
  hasSelectedItems: boolean;
96
96
  isTypingAhead: boolean;
97
97
  isInteractive: boolean;
98
98
  isDisabled: boolean;
99
+ selectedItems: T[];
99
100
  valueAsString: string;
100
101
  };
101
102
  refs: {
@@ -1,11 +1,11 @@
1
1
  import { t as createAnatomy } from "../../create-anatomy-Dr0evdYy.mjs";
2
2
  import { $t as contains, G as getInitialFocus, I as scrollIntoView, K as isValidTabEvent, W as raf, a as visuallyHiddenStyle, at as isInternalChangeEvent, bn as ariaAttr, ft as getEventKey, gt as getNativeEvent, ht as getEventTarget, lt as trackFormControl, ot as markAsInternalChangeEvent, s as getByTypeahead, un as isEditableElement, xn as dataAttr, z as observeAttributes } from "../../dom-query-BFuRs3l4.mjs";
3
3
  import { ft as isEqual, mt as addOrRemove, t as ensure, u as createSplitProps } from "../../utils-VVoZ_v29.mjs";
4
- import { s as ListCollection } from "../../collection-DgzidRvr.mjs";
4
+ import { a as createSelectedItemMap, d as ListCollection, o as deriveSelectionState, s as resolveSelectedItems } from "../../collection-GSpaYJ2f.mjs";
5
5
  import { a as createMachine, i as createGuards } from "../../core-CTtbW9qh.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/select/select.anatomy.ts
@@ -55,7 +55,7 @@ function connect(service, normalize) {
55
55
  const focused = state.matches("focused");
56
56
  const highlightedValue = context.get("highlightedValue");
57
57
  const highlightedItem = context.get("highlightedItem");
58
- const selectedItems = context.get("selectedItems");
58
+ const selectedItems = computed("selectedItems");
59
59
  const currentPlacement = context.get("currentPlacement");
60
60
  const isTypingAhead = computed("isTypingAhead");
61
61
  const interactive = computed("isInteractive");
@@ -507,17 +507,32 @@ const machine = createMachine({
507
507
  }
508
508
  };
509
509
  },
510
- context({ prop, bindable }) {
510
+ context({ prop, bindable, getContext }) {
511
+ const initialValue = prop("value") ?? prop("defaultValue") ?? [];
512
+ const initialSelectedItems = prop("collection").findMany(initialValue);
511
513
  return {
512
514
  value: bindable(() => ({
513
515
  defaultValue: prop("defaultValue"),
514
516
  value: prop("value"),
515
517
  isEqual,
516
518
  onChange(value) {
517
- const items = prop("collection").findMany(value);
519
+ const context = getContext();
520
+ const collection = prop("collection");
521
+ const proposed = deriveSelectionState({
522
+ values: value,
523
+ collection,
524
+ selectedItemMap: context.get("selectedItemMap")
525
+ });
526
+ const effectiveValue = prop("value") ?? value;
527
+ const effective = effectiveValue === value ? proposed : deriveSelectionState({
528
+ values: effectiveValue,
529
+ collection,
530
+ selectedItemMap: proposed.nextSelectedItemMap
531
+ });
532
+ context.set("selectedItemMap", effective.nextSelectedItemMap);
518
533
  return prop("onValueChange")?.({
519
534
  value,
520
- items
535
+ items: proposed.selectedItems
521
536
  });
522
537
  }
523
538
  })),
@@ -535,9 +550,11 @@ const machine = createMachine({
535
550
  currentPlacement: bindable(() => ({ defaultValue: void 0 })),
536
551
  fieldsetDisabled: bindable(() => ({ defaultValue: false })),
537
552
  highlightedItem: bindable(() => ({ defaultValue: null })),
538
- selectedItems: bindable(() => {
539
- const value = prop("value") ?? prop("defaultValue") ?? [];
540
- return { defaultValue: prop("collection").findMany(value) };
553
+ selectedItemMap: bindable(() => {
554
+ return { defaultValue: createSelectedItemMap({
555
+ selectedItems: initialSelectedItems,
556
+ collection: prop("collection")
557
+ }) };
541
558
  })
542
559
  };
543
560
  },
@@ -549,7 +566,12 @@ const machine = createMachine({
549
566
  isTypingAhead: ({ refs }) => refs.get("typeahead").keysSoFar !== "",
550
567
  isDisabled: ({ prop, context }) => !!prop("disabled") || !!context.get("fieldsetDisabled"),
551
568
  isInteractive: ({ prop }) => !(prop("disabled") || prop("readOnly")),
552
- valueAsString: ({ context, prop }) => prop("collection").stringifyItems(context.get("selectedItems"))
569
+ selectedItems: ({ context, prop }) => resolveSelectedItems({
570
+ values: context.get("value"),
571
+ collection: prop("collection"),
572
+ selectedItemMap: context.get("selectedItemMap")
573
+ }),
574
+ valueAsString: ({ computed, prop }) => prop("collection").stringifyItems(computed("selectedItems"))
553
575
  },
554
576
  initialState({ prop }) {
555
577
  return prop("open") || prop("defaultOpen") ? "open" : "idle";
@@ -882,7 +904,7 @@ const machine = createMachine({
882
904
  const exec = (immediate) => {
883
905
  const highlightedValue = context.get("highlightedValue");
884
906
  if (highlightedValue == null) return;
885
- if (getInteractionModality() !== "keyboard") return;
907
+ if (getInteractionModality() === "pointer") return;
886
908
  const contentEl = getContentEl(scope);
887
909
  const scrollToIndexFn = prop("scrollToIndexFn");
888
910
  if (scrollToIndexFn) {
@@ -899,7 +921,10 @@ const machine = createMachine({
899
921
  block: "nearest"
900
922
  });
901
923
  };
902
- raf(() => exec(true));
924
+ raf(() => {
925
+ setInteractionModality("virtual");
926
+ exec(true);
927
+ });
903
928
  const contentEl = () => getContentEl(scope);
904
929
  return observeAttributes(contentEl, {
905
930
  defer: true,
@@ -1084,16 +1109,20 @@ const machine = createMachine({
1084
1109
  const collection = prop("collection");
1085
1110
  const highlightedItem = collection.find(context.get("highlightedValue"));
1086
1111
  if (highlightedItem) context.set("highlightedItem", highlightedItem);
1087
- const selectedItems = collection.findMany(context.get("value"));
1088
- context.set("selectedItems", selectedItems);
1112
+ const next = deriveSelectionState({
1113
+ values: context.get("value"),
1114
+ collection,
1115
+ selectedItemMap: context.get("selectedItemMap")
1116
+ });
1117
+ context.set("selectedItemMap", next.nextSelectedItemMap);
1089
1118
  },
1090
1119
  syncSelectedItems({ context, prop }) {
1091
- const collection = prop("collection");
1092
- const prevSelectedItems = context.get("selectedItems");
1093
- const selectedItems = context.get("value").map((value) => {
1094
- return prevSelectedItems.find((item) => collection.getItemValue(item) === value) || collection.find(value);
1120
+ const next = deriveSelectionState({
1121
+ values: context.get("value"),
1122
+ collection: prop("collection"),
1123
+ selectedItemMap: context.get("selectedItemMap")
1095
1124
  });
1096
- context.set("selectedItems", selectedItems);
1125
+ context.set("selectedItemMap", next.nextSelectedItemMap);
1097
1126
  },
1098
1127
  syncHighlightedItem({ context, prop }) {
1099
1128
  const collection = prop("collection");
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as Comm
4
4
  import { StrokeOptions } from "perfect-freehand";
5
5
 
6
6
  //#region src/machines/signature-pad/signature-pad.anatomy.d.ts
7
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "clearTrigger" | "segment" | "segmentPath" | "guide">;
7
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "segment" | "segmentPath" | "guide" | "clearTrigger">;
8
8
  //#endregion
9
9
  //#region src/machines/signature-pad/signature-pad.types.d.ts
10
10
  interface Point {
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as Comm
4
4
  import { StrokeOptions } from "perfect-freehand";
5
5
 
6
6
  //#region src/machines/signature-pad/signature-pad.anatomy.d.ts
7
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "clearTrigger" | "segment" | "segmentPath" | "guide">;
7
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "segment" | "segmentPath" | "guide" | "clearTrigger">;
8
8
  //#endregion
9
9
  //#region src/machines/signature-pad/signature-pad.types.d.ts
10
10
  interface Point {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
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/slider/slider.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "label" | "track" | "control" | "marker" | "thumb" | "valueText" | "markerGroup" | "range" | "draggingIndicator">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "control" | "track" | "markerGroup" | "marker" | "range" | "draggingIndicator">;
7
7
  //#endregion
8
8
  //#region src/machines/slider/slider.types.d.ts
9
9
  type ThumbCollisionBehavior = "none" | "push" | "swap";
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
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/slider/slider.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "label" | "track" | "control" | "marker" | "thumb" | "valueText" | "markerGroup" | "range" | "draggingIndicator">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "control" | "track" | "markerGroup" | "marker" | "range" | "draggingIndicator">;
7
7
  //#endregion
8
8
  //#region src/machines/slider/slider.types.d.ts
9
9
  type ThumbCollisionBehavior = "none" | "push" | "swap";
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
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/steps/steps.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "trigger" | "indicator" | "content" | "item" | "nextTrigger" | "prevTrigger" | "progress" | "list" | "separator">;
6
+ declare const anatomy: AnatomyInstance<"root" | "content" | "trigger" | "indicator" | "item" | "separator" | "list" | "progress" | "nextTrigger" | "prevTrigger">;
7
7
  //#endregion
8
8
  //#region src/machines/steps/steps.types.d.ts
9
9
  interface StepChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
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/steps/steps.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "trigger" | "indicator" | "content" | "item" | "nextTrigger" | "prevTrigger" | "progress" | "list" | "separator">;
6
+ declare const anatomy: AnatomyInstance<"root" | "content" | "trigger" | "indicator" | "item" | "separator" | "list" | "progress" | "nextTrigger" | "prevTrigger">;
7
7
  //#endregion
8
8
  //#region src/machines/steps/steps.types.d.ts
9
9
  interface StepChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
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/switch/switch.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "thumb">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "thumb" | "control">;
7
7
  //#endregion
8
8
  //#region src/machines/switch/switch.types.d.ts
9
9
  interface CheckedChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
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/switch/switch.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "thumb">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "thumb" | "control">;
7
7
  //#endregion
8
8
  //#region src/machines/switch/switch.types.d.ts
9
9
  interface CheckedChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
3
3
  import { b as NormalizeProps, g as RequiredBy, m as Rect, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
4
4
 
5
5
  //#region src/machines/tabs/tabs.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "trigger" | "indicator" | "content" | "list">;
6
+ declare const anatomy: AnatomyInstance<"root" | "content" | "trigger" | "indicator" | "list">;
7
7
  //#endregion
8
8
  //#region src/machines/tabs/tabs.types.d.ts
9
9
  interface ValueChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
3
3
  import { b as NormalizeProps, g as RequiredBy, m as Rect, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
4
4
 
5
5
  //#region src/machines/tabs/tabs.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "trigger" | "indicator" | "content" | "list">;
6
+ declare const anatomy: AnatomyInstance<"root" | "content" | "trigger" | "indicator" | "list">;
7
7
  //#endregion
8
8
  //#region src/machines/tabs/tabs.types.d.ts
9
9
  interface ValueChangeDetails {
@@ -5,7 +5,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
5
5
  import { t as LiveRegion } from "../../index-BO-Z3fhz.cjs";
6
6
 
7
7
  //#region src/machines/tags-input/tags-input.anatomy.d.ts
8
- declare const anatomy: AnatomyInstance<"root" | "input" | "label" | "control" | "item" | "itemText" | "clearTrigger" | "itemPreview" | "itemInput" | "itemDeleteTrigger">;
8
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "item" | "input" | "itemText" | "clearTrigger" | "itemDeleteTrigger" | "itemPreview" | "itemInput">;
9
9
  //#endregion
10
10
  //#region src/machines/tags-input/tags-input.types.d.ts
11
11
  interface ValueChangeDetails {
@@ -5,7 +5,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
5
5
  import { t as LiveRegion } from "../../index-1L40UHp8.mjs";
6
6
 
7
7
  //#region src/machines/tags-input/tags-input.anatomy.d.ts
8
- declare const anatomy: AnatomyInstance<"root" | "input" | "label" | "control" | "item" | "itemText" | "clearTrigger" | "itemPreview" | "itemInput" | "itemDeleteTrigger">;
8
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "item" | "input" | "itemText" | "clearTrigger" | "itemDeleteTrigger" | "itemPreview" | "itemInput">;
9
9
  //#endregion
10
10
  //#region src/machines/tags-input/tags-input.types.d.ts
11
11
  interface ValueChangeDetails {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-u-LWCS
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/timer/timer.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "area" | "itemLabel" | "actionTrigger" | "itemValue" | "separator">;
6
+ declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "itemLabel" | "actionTrigger" | "area" | "itemValue" | "separator">;
7
7
  //#endregion
8
8
  //#region src/machines/timer/timer.types.d.ts
9
9
  interface Time<T = number> {
@@ -3,7 +3,7 @@ import { b as Service, p as Machine, u as EventObject } from "../../types-DvUmCW
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/timer/timer.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "area" | "itemLabel" | "actionTrigger" | "itemValue" | "separator">;
6
+ declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "itemLabel" | "actionTrigger" | "area" | "itemValue" | "separator">;
7
7
  //#endregion
8
8
  //#region src/machines/timer/timer.types.d.ts
9
9
  interface Time<T = number> {
@@ -175,7 +175,7 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
175
175
  declare function groupConnect<T extends PropTypes, O = any>(service: Service<ToastGroupSchema>, normalize: NormalizeProps<T>): ToastGroupApi<T, O>;
176
176
  //#endregion
177
177
  //#region src/machines/toast/toast.anatomy.d.ts
178
- declare const anatomy: AnatomyInstance<"root" | "title" | "group" | "description" | "actionTrigger" | "closeTrigger">;
178
+ declare const anatomy: AnatomyInstance<"root" | "group" | "title" | "description" | "actionTrigger" | "closeTrigger">;
179
179
  //#endregion
180
180
  //#region src/machines/toast/toast.connect.d.ts
181
181
  declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
@@ -175,7 +175,7 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
175
175
  declare function groupConnect<T extends PropTypes, O = any>(service: Service<ToastGroupSchema>, normalize: NormalizeProps<T>): ToastGroupApi<T, O>;
176
176
  //#endregion
177
177
  //#region src/machines/toast/toast.anatomy.d.ts
178
- declare const anatomy: AnatomyInstance<"root" | "title" | "group" | "description" | "actionTrigger" | "closeTrigger">;
178
+ declare const anatomy: AnatomyInstance<"root" | "group" | "title" | "description" | "actionTrigger" | "closeTrigger">;
179
179
  //#endregion
180
180
  //#region src/machines/toast/toast.connect.d.ts
181
181
  declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;