@sprawlify/primitives 0.0.51 → 0.0.53

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 (101) hide show
  1. package/dist/{collection-C85P2ZDW.mjs → collection-CjwZd09Z.mjs} +7 -1
  2. package/dist/{collection-C5tUixCe.cjs → collection-Q52RkxUe.cjs} +7 -1
  3. package/dist/collection.cjs +1 -1
  4. package/dist/collection.d.cts +3 -3
  5. package/dist/collection.d.mts +3 -3
  6. package/dist/collection.mjs +1 -1
  7. package/dist/dom-query.d.cts +1 -1
  8. package/dist/dom-query.d.mts +1 -1
  9. package/dist/{list-collection-DettiQL3.d.cts → list-collection-BslnP0r-.d.cts} +1 -1
  10. package/dist/{list-collection-BbgocToA.d.mts → list-collection-swuCMCIS.d.mts} +1 -1
  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/bottom-sheet/index.d.cts +1 -1
  14. package/dist/machines/bottom-sheet/index.d.mts +1 -1
  15. package/dist/machines/carousel/index.d.cts +1 -1
  16. package/dist/machines/carousel/index.d.mts +1 -1
  17. package/dist/machines/checkbox/index.d.cts +1 -1
  18. package/dist/machines/checkbox/index.d.mts +1 -1
  19. package/dist/machines/clipboard/index.d.cts +1 -1
  20. package/dist/machines/clipboard/index.d.mts +1 -1
  21. package/dist/machines/collapsible/index.d.cts +1 -1
  22. package/dist/machines/collapsible/index.d.mts +1 -1
  23. package/dist/machines/color-picker/index.d.cts +1 -1
  24. package/dist/machines/color-picker/index.d.mts +1 -1
  25. package/dist/machines/combobox/index.cjs +1 -1
  26. package/dist/machines/combobox/index.d.cts +2 -2
  27. package/dist/machines/combobox/index.d.mts +2 -2
  28. package/dist/machines/combobox/index.mjs +1 -1
  29. package/dist/machines/date-picker/index.d.cts +1 -1
  30. package/dist/machines/date-picker/index.d.mts +1 -1
  31. package/dist/machines/dialog/index.d.cts +1 -1
  32. package/dist/machines/dialog/index.d.mts +1 -1
  33. package/dist/machines/editable/index.d.cts +1 -1
  34. package/dist/machines/editable/index.d.mts +1 -1
  35. package/dist/machines/file-upload/index.d.cts +1 -1
  36. package/dist/machines/file-upload/index.d.mts +1 -1
  37. package/dist/machines/floating-panel/index.d.cts +1 -1
  38. package/dist/machines/floating-panel/index.d.mts +1 -1
  39. package/dist/machines/hover-card/index.d.cts +1 -1
  40. package/dist/machines/hover-card/index.d.mts +1 -1
  41. package/dist/machines/image-cropper/index.d.cts +1 -1
  42. package/dist/machines/image-cropper/index.d.mts +1 -1
  43. package/dist/machines/listbox/index.cjs +1 -1
  44. package/dist/machines/listbox/index.d.cts +3 -3
  45. package/dist/machines/listbox/index.d.mts +3 -3
  46. package/dist/machines/listbox/index.mjs +1 -1
  47. package/dist/machines/marquee/index.d.cts +3 -3
  48. package/dist/machines/marquee/index.d.mts +3 -3
  49. package/dist/machines/menu/index.d.cts +1 -1
  50. package/dist/machines/menu/index.d.mts +1 -1
  51. package/dist/machines/navigation-menu/index.d.cts +1 -1
  52. package/dist/machines/navigation-menu/index.d.mts +1 -1
  53. package/dist/machines/number-input/index.d.cts +1 -1
  54. package/dist/machines/number-input/index.d.mts +1 -1
  55. package/dist/machines/password-input/index.d.cts +1 -1
  56. package/dist/machines/password-input/index.d.mts +1 -1
  57. package/dist/machines/pin-input/index.d.cts +1 -1
  58. package/dist/machines/pin-input/index.d.mts +1 -1
  59. package/dist/machines/popover/index.d.cts +1 -1
  60. package/dist/machines/popover/index.d.mts +1 -1
  61. package/dist/machines/progress/index.d.cts +1 -1
  62. package/dist/machines/progress/index.d.mts +1 -1
  63. package/dist/machines/rating-group/index.d.cts +1 -1
  64. package/dist/machines/rating-group/index.d.mts +1 -1
  65. package/dist/machines/scroll-area/index.d.cts +1 -1
  66. package/dist/machines/scroll-area/index.d.mts +1 -1
  67. package/dist/machines/select/index.cjs +1 -1
  68. package/dist/machines/select/index.d.cts +2 -2
  69. package/dist/machines/select/index.d.mts +2 -2
  70. package/dist/machines/select/index.mjs +1 -1
  71. package/dist/machines/signature-pad/index.d.cts +1 -1
  72. package/dist/machines/signature-pad/index.d.mts +1 -1
  73. package/dist/machines/slider/index.d.cts +1 -1
  74. package/dist/machines/slider/index.d.mts +1 -1
  75. package/dist/machines/steps/index.cjs +69 -23
  76. package/dist/machines/steps/index.d.cts +14 -2
  77. package/dist/machines/steps/index.d.mts +14 -2
  78. package/dist/machines/steps/index.mjs +69 -23
  79. package/dist/machines/switch/index.d.cts +1 -1
  80. package/dist/machines/switch/index.d.mts +1 -1
  81. package/dist/machines/tabs/index.d.cts +1 -1
  82. package/dist/machines/tabs/index.d.mts +1 -1
  83. package/dist/machines/tags-input/index.d.cts +1 -1
  84. package/dist/machines/tags-input/index.d.mts +1 -1
  85. package/dist/machines/timer/index.d.cts +1 -1
  86. package/dist/machines/timer/index.d.mts +1 -1
  87. package/dist/machines/toast/index.d.cts +1 -1
  88. package/dist/machines/toast/index.d.mts +1 -1
  89. package/dist/machines/tooltip/index.d.cts +1 -1
  90. package/dist/machines/tooltip/index.d.mts +1 -1
  91. package/dist/machines/tour/index.d.cts +1 -1
  92. package/dist/machines/tour/index.d.mts +1 -1
  93. package/dist/machines/tree-view/index.cjs +11 -6
  94. package/dist/machines/tree-view/index.d.cts +2 -2
  95. package/dist/machines/tree-view/index.d.mts +2 -2
  96. package/dist/machines/tree-view/index.mjs +11 -6
  97. package/dist/{selection-CTaapzrB.d.mts → selection-CIoBu9mp.d.mts} +1 -1
  98. package/dist/{selection-D3b3yV_x.d.cts → selection-DTpiPgq8.d.cts} +1 -1
  99. package/dist/{tree-collection-Dlv1BAsc.d.cts → tree-collection-CmehimuO.d.cts} +1 -1
  100. package/dist/{tree-collection-DYIVkVee.d.mts → tree-collection-CqXQBHwY.d.mts} +1 -1
  101. package/package.json +1 -1
@@ -24,6 +24,12 @@ function connect(service, normalize) {
24
24
  const percent = computed("percent");
25
25
  const hasNextStep = computed("hasNextStep");
26
26
  const hasPrevStep = computed("hasPrevStep");
27
+ const isStepValid = (index) => {
28
+ return prop("isStepValid")?.(index) ?? true;
29
+ };
30
+ const isStepSkippable = (index) => {
31
+ return prop("isStepSkippable")?.(index) ?? false;
32
+ };
27
33
  const getItemState = (props$1) => ({
28
34
  triggerId: getTriggerId(scope, props$1.index),
29
35
  contentId: getContentId(scope, props$1.index),
@@ -32,7 +38,9 @@ function connect(service, normalize) {
32
38
  incomplete: props$1.index > step,
33
39
  index: props$1.index,
34
40
  first: props$1.index === 0,
35
- last: props$1.index === count - 1
41
+ last: props$1.index === count - 1,
42
+ skippable: isStepSkippable(props$1.index),
43
+ isValid: () => isStepValid(props$1.index)
36
44
  });
37
45
  const goToNextStep = () => {
38
46
  send({
@@ -66,6 +74,8 @@ function connect(service, normalize) {
66
74
  hasNextStep,
67
75
  hasPrevStep,
68
76
  isCompleted: computed("completed"),
77
+ isStepValid,
78
+ isStepSkippable,
69
79
  goToNextStep,
70
80
  goToPrevStep,
71
81
  resetStep,
@@ -98,7 +108,8 @@ function connect(service, normalize) {
98
108
  ...parts.item.attrs,
99
109
  dir: prop("dir"),
100
110
  "aria-current": itemState.current ? "step" : void 0,
101
- "data-orientation": prop("orientation")
111
+ "data-orientation": prop("orientation"),
112
+ "data-skippable": dataAttr(itemState.skippable)
102
113
  });
103
114
  },
104
115
  getTriggerProps(props$1) {
@@ -233,34 +244,65 @@ const machine = createMachine({
233
244
  initialState() {
234
245
  return "idle";
235
246
  },
236
- entry: ["validateStep"],
247
+ entry: ["validateStepIndex"],
237
248
  states: { idle: { on: {
238
- "STEP.SET": { actions: ["setStep"] },
239
- "STEP.NEXT": { actions: ["goToNextStep"] },
249
+ "STEP.SET": [{
250
+ guard: "isValidStepNavigation",
251
+ actions: ["setStep"]
252
+ }, { actions: ["invokeOnStepInvalid"] }],
253
+ "STEP.NEXT": [{
254
+ guard: "isCurrentStepValid",
255
+ actions: ["goToNextStep"]
256
+ }, { actions: ["invokeOnStepInvalid"] }],
240
257
  "STEP.PREV": { actions: ["goToPrevStep"] },
241
258
  "STEP.RESET": { actions: ["resetStep"] }
242
259
  } } },
243
- implementations: { actions: {
244
- goToNextStep({ context, prop }) {
245
- const value = Math.min(context.get("step") + 1, prop("count"));
246
- context.set("step", value);
247
- },
248
- goToPrevStep({ context }) {
249
- const value = Math.max(context.get("step") - 1, 0);
250
- context.set("step", value);
251
- },
252
- resetStep({ context }) {
253
- context.set("step", 0);
254
- },
255
- setStep({ context, event }) {
256
- context.set("step", event.value);
260
+ implementations: {
261
+ guards: {
262
+ isCurrentStepValid({ context, prop }) {
263
+ const current = context.get("step");
264
+ if (prop("isStepSkippable")?.(current)) return true;
265
+ const isStepValid = prop("isStepValid");
266
+ if (!isStepValid) return true;
267
+ return isStepValid(current);
268
+ },
269
+ isValidStepNavigation({ context, event, prop }) {
270
+ const current = context.get("step");
271
+ if (event.value <= current) return true;
272
+ if (prop("isStepSkippable")?.(current)) return true;
273
+ const isStepValid = prop("isStepValid");
274
+ if (!isStepValid) return true;
275
+ return isStepValid(current);
276
+ }
257
277
  },
258
- validateStep({ context, prop }) {
259
- validateStep(prop("count"), context.get("step"));
278
+ actions: {
279
+ goToNextStep({ context, prop }) {
280
+ const count = prop("count");
281
+ context.set("step", Math.min(context.get("step") + 1, count));
282
+ },
283
+ goToPrevStep({ context }) {
284
+ context.set("step", Math.max(context.get("step") - 1, 0));
285
+ },
286
+ resetStep({ context }) {
287
+ context.set("step", 0);
288
+ },
289
+ setStep({ context, event }) {
290
+ context.set("step", event.value);
291
+ },
292
+ validateStepIndex({ context, prop }) {
293
+ validateStepIndex(prop("count"), context.get("step"));
294
+ },
295
+ invokeOnStepInvalid({ context, event, prop }) {
296
+ prop("onStepInvalid")?.({
297
+ step: context.get("step"),
298
+ action: event.type === "STEP.NEXT" ? "next" : "set",
299
+ targetStep: event.value
300
+ });
301
+ }
260
302
  }
261
- } }
303
+ }
262
304
  });
263
- const validateStep = (count, step) => {
305
+ const validateStepIndex = (count, step) => {
264
306
  if (!isValueWithinRange(step, 0, count)) throw new RangeError(`[sprawlify-js/steps] step index ${step} is out of bounds`);
265
307
  };
266
308
 
@@ -268,13 +310,17 @@ const validateStep = (count, step) => {
268
310
  //#region src/machines/steps/steps.props.ts
269
311
  const props = createProps()([
270
312
  "count",
313
+ "defaultStep",
271
314
  "dir",
272
315
  "getRootNode",
273
316
  "id",
274
317
  "ids",
318
+ "isStepSkippable",
319
+ "isStepValid",
275
320
  "linear",
276
321
  "onStepChange",
277
322
  "onStepComplete",
323
+ "onStepInvalid",
278
324
  "orientation",
279
325
  "step",
280
326
  "defaultStep"
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DejIu6
3
3
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-Bqw3r34-.cjs";
4
4
 
5
5
  //#region src/machines/switch/switch.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "control" | "label" | "thumb">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "thumb">;
7
7
  //#endregion
8
8
  //#region src/machines/switch/switch.types.d.ts
9
9
  interface CheckedChangeDetails {
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DL5AIQ
3
3
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BuUzJjaP.mjs";
4
4
 
5
5
  //#region src/machines/switch/switch.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "control" | "label" | "thumb">;
6
+ declare const anatomy: AnatomyInstance<"root" | "label" | "control" | "thumb">;
7
7
  //#endregion
8
8
  //#region src/machines/switch/switch.types.d.ts
9
9
  interface CheckedChangeDetails {
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DejIu6
3
3
  import { b as NormalizeProps, g as RequiredBy, m as Rect, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-Bqw3r34-.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<"content" | "trigger" | "root" | "indicator" | "list">;
7
7
  //#endregion
8
8
  //#region src/machines/tabs/tabs.types.d.ts
9
9
  interface ValueChangeDetails {
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DL5AIQ
3
3
  import { b as NormalizeProps, g as RequiredBy, m as Rect, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BuUzJjaP.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<"content" | "trigger" | "root" | "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-Owca7uxB.cjs";
6
6
 
7
7
  //#region src/machines/tags-input/tags-input.anatomy.d.ts
8
- declare const anatomy: AnatomyInstance<"root" | "control" | "input" | "label" | "item" | "itemText" | "clearTrigger" | "itemDeleteTrigger" | "itemInput" | "itemPreview">;
8
+ declare const anatomy: AnatomyInstance<"input" | "root" | "label" | "control" | "item" | "itemDeleteTrigger" | "itemInput" | "clearTrigger" | "itemText" | "itemPreview">;
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-CygfPLvT.mjs";
6
6
 
7
7
  //#region src/machines/tags-input/tags-input.anatomy.d.ts
8
- declare const anatomy: AnatomyInstance<"root" | "control" | "input" | "label" | "item" | "itemText" | "clearTrigger" | "itemDeleteTrigger" | "itemInput" | "itemPreview">;
8
+ declare const anatomy: AnatomyInstance<"input" | "root" | "label" | "control" | "item" | "itemDeleteTrigger" | "itemInput" | "clearTrigger" | "itemText" | "itemPreview">;
9
9
  //#endregion
10
10
  //#region src/machines/tags-input/tags-input.types.d.ts
11
11
  interface ValueChangeDetails {
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DejIu6
3
3
  import { b as NormalizeProps, g as RequiredBy, t as CommonProperties, x as PropTypes } from "../../index-Bqw3r34-.cjs";
4
4
 
5
5
  //#region src/machines/timer/timer.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "area" | "itemValue" | "itemLabel" | "actionTrigger" | "separator">;
6
+ declare const anatomy: AnatomyInstance<"actionTrigger" | "root" | "control" | "item" | "area" | "separator" | "itemLabel" | "itemValue">;
7
7
  //#endregion
8
8
  //#region src/machines/timer/timer.types.d.ts
9
9
  interface Time<T = number> {
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DL5AIQ
3
3
  import { b as NormalizeProps, g as RequiredBy, t as CommonProperties, x as PropTypes } from "../../index-BuUzJjaP.mjs";
4
4
 
5
5
  //#region src/machines/timer/timer.anatomy.d.ts
6
- declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "area" | "itemValue" | "itemLabel" | "actionTrigger" | "separator">;
6
+ declare const anatomy: AnatomyInstance<"actionTrigger" | "root" | "control" | "item" | "area" | "separator" | "itemLabel" | "itemValue">;
7
7
  //#endregion
8
8
  //#region src/machines/timer/timer.types.d.ts
9
9
  interface Time<T = number> {
@@ -176,7 +176,7 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
176
176
  declare function groupConnect<T extends PropTypes, O = any>(service: Service<ToastGroupSchema>, normalize: NormalizeProps<T>): ToastGroupApi<T, O>;
177
177
  //#endregion
178
178
  //#region src/machines/toast/toast.anatomy.d.ts
179
- declare const anatomy: AnatomyInstance<"root" | "actionTrigger" | "title" | "group" | "description" | "closeTrigger">;
179
+ declare const anatomy: AnatomyInstance<"actionTrigger" | "closeTrigger" | "title" | "description" | "root" | "group">;
180
180
  //#endregion
181
181
  //#region src/machines/toast/toast.connect.d.ts
182
182
  declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
@@ -176,7 +176,7 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
176
176
  declare function groupConnect<T extends PropTypes, O = any>(service: Service<ToastGroupSchema>, normalize: NormalizeProps<T>): ToastGroupApi<T, O>;
177
177
  //#endregion
178
178
  //#region src/machines/toast/toast.anatomy.d.ts
179
- declare const anatomy: AnatomyInstance<"root" | "actionTrigger" | "title" | "group" | "description" | "closeTrigger">;
179
+ declare const anatomy: AnatomyInstance<"actionTrigger" | "closeTrigger" | "title" | "description" | "root" | "group">;
180
180
  //#endregion
181
181
  //#region src/machines/toast/toast.connect.d.ts
182
182
  declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as Comm
4
4
  import { c as Placement, d as PositioningOptions } from "../../types-D5ziaMrd.cjs";
5
5
 
6
6
  //#region src/machines/tooltip/tooltip.anatomy.d.ts
7
- declare const anatomy: AnatomyInstance<"trigger" | "content" | "arrow" | "positioner" | "arrowTip">;
7
+ declare const anatomy: AnatomyInstance<"content" | "positioner" | "arrow" | "arrowTip" | "trigger">;
8
8
  //#endregion
9
9
  //#region src/machines/tooltip/tooltip.types.d.ts
10
10
  interface OpenChangeDetails {
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as Comm
4
4
  import { p as PositioningOptions, u as Placement } from "../../index-BTi1wETB.mjs";
5
5
 
6
6
  //#region src/machines/tooltip/tooltip.anatomy.d.ts
7
- declare const anatomy: AnatomyInstance<"trigger" | "content" | "arrow" | "positioner" | "arrowTip">;
7
+ declare const anatomy: AnatomyInstance<"content" | "positioner" | "arrow" | "arrowTip" | "trigger">;
8
8
  //#endregion
9
9
  //#region src/machines/tooltip/tooltip.types.d.ts
10
10
  interface OpenChangeDetails {
@@ -6,7 +6,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
6
6
  import { c as Placement } from "../../types-D5ziaMrd.cjs";
7
7
 
8
8
  //#region src/machines/tour/tour.anatomy.d.ts
9
- declare const anatomy: AnatomyInstance<"content" | "arrow" | "actionTrigger" | "positioner" | "arrowTip" | "title" | "progressText" | "description" | "closeTrigger" | "backdrop" | "spotlight">;
9
+ declare const anatomy: AnatomyInstance<"content" | "actionTrigger" | "closeTrigger" | "progressText" | "title" | "description" | "positioner" | "arrow" | "arrowTip" | "backdrop" | "spotlight">;
10
10
  //#endregion
11
11
  //#region src/machines/tour/utils/rect.d.ts
12
12
  interface Point {
@@ -6,7 +6,7 @@ import { c as PointerDownOutsideEvent, i as InteractOutsideHandlers, n as FocusO
6
6
  import { u as Placement } from "../../index-BTi1wETB.mjs";
7
7
 
8
8
  //#region src/machines/tour/tour.anatomy.d.ts
9
- declare const anatomy: AnatomyInstance<"content" | "arrow" | "actionTrigger" | "positioner" | "arrowTip" | "title" | "progressText" | "description" | "closeTrigger" | "backdrop" | "spotlight">;
9
+ declare const anatomy: AnatomyInstance<"content" | "actionTrigger" | "closeTrigger" | "progressText" | "title" | "description" | "positioner" | "arrow" | "arrowTip" | "backdrop" | "spotlight">;
10
10
  //#endregion
11
11
  //#region src/machines/tour/utils/rect.d.ts
12
12
  interface Point {
@@ -1,7 +1,7 @@
1
1
  const require_create_anatomy = require('../../create-anatomy-CDsIFUXg.cjs');
2
2
  const require_dom_query = require('../../dom-query-ClqjTSZC.cjs');
3
3
  const require_utils = require('../../utils-B4_qn2dt.cjs');
4
- const require_collection = require('../../collection-C5tUixCe.cjs');
4
+ const require_collection = require('../../collection-Q52RkxUe.cjs');
5
5
  const require_core = require('../../core-NCx2blZX.cjs');
6
6
  const require_create_props = require('../../create-props-l5q5b8Wo.cjs');
7
7
 
@@ -76,18 +76,21 @@ function connect(service, normalize) {
76
76
  const focusedValue = context.get("focusedValue");
77
77
  const loadingStatus = context.get("loadingStatus");
78
78
  const renamingValue = context.get("renamingValue");
79
+ const skip = ({ indexPath }) => {
80
+ return collection$1.getValuePath(indexPath).slice(0, -1).some((value) => !expandedValue.includes(value));
81
+ };
82
+ const firstNode = collection$1.getFirstNode(void 0, { skip });
83
+ const firstNodeValue = firstNode ? collection$1.getNodeValue(firstNode) : null;
79
84
  function getNodeState(props$1) {
80
85
  const { node, indexPath } = props$1;
81
86
  const value = collection$1.getNodeValue(node);
82
- const firstNode = collection$1.getFirstNode();
83
- const firstNodeValue = firstNode ? collection$1.getNodeValue(firstNode) : null;
84
87
  return {
85
88
  id: getNodeId(scope, value),
86
89
  value,
87
90
  indexPath,
88
91
  valuePath: collection$1.getValuePath(indexPath),
89
92
  disabled: Boolean(node.disabled),
90
- focused: focusedValue == null ? firstNodeValue == value : focusedValue === value,
93
+ focused: focusedValue == null ? firstNodeValue === value : focusedValue === value,
91
94
  selected: selectedValue.includes(value),
92
95
  expanded: expandedValue.includes(value),
93
96
  loading: loadingStatus[value] === "loading",
@@ -971,7 +974,8 @@ const machine = require_core.createMachine({
971
974
  focusTreeFirstNode(params) {
972
975
  const { prop, scope } = params;
973
976
  const collection$1 = prop("collection");
974
- const firstNode = collection$1.getFirstNode();
977
+ const firstNode = collection$1.getFirstNode(void 0, { skip: skipFn(params) });
978
+ if (!firstNode) return;
975
979
  const firstValue = collection$1.getNodeValue(firstNode);
976
980
  if (scrollToNode(params, firstValue)) require_dom_query.raf(() => focusNode(scope, firstValue));
977
981
  else focusNode(scope, firstValue);
@@ -988,7 +992,8 @@ const machine = require_core.createMachine({
988
992
  const { event, prop, scope } = params;
989
993
  const collection$1 = prop("collection");
990
994
  const branchNode = collection$1.findNode(event.id);
991
- const firstNode = collection$1.getFirstNode(branchNode);
995
+ const firstNode = collection$1.getFirstNode(branchNode, { skip: skipFn(params) });
996
+ if (!firstNode) return;
992
997
  const firstValue = collection$1.getNodeValue(firstNode);
993
998
  if (scrollToNode(params, firstValue)) require_dom_query.raf(() => focusNode(scope, firstValue));
994
999
  else focusNode(scope, firstValue);
@@ -1,12 +1,12 @@
1
1
  import { n as AnatomyInstance } from "../../create-anatomy-smWrirg1.cjs";
2
2
  import { f as TreeCollectionOptions, g as ValuePath, p as TreeNode, s as FilePathTreeNode, u as IndexPath } from "../../types-CADkcKtr.cjs";
3
- import { t as TreeCollection } from "../../tree-collection-Dlv1BAsc.cjs";
3
+ import { t as TreeCollection } from "../../tree-collection-CmehimuO.cjs";
4
4
  import { p as Machine, y as Service } from "../../types-DejIu60O.cjs";
5
5
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-Bqw3r34-.cjs";
6
6
  import { n as TypeaheadState } from "../../typeahead-BdNwVP09.cjs";
7
7
 
8
8
  //#region src/machines/tree-view/tree-view.anatomy.d.ts
9
- declare const anatomy: AnatomyInstance<"root" | "label" | "item" | "itemIndicator" | "branch" | "branchContent" | "branchControl" | "branchIndentGuide" | "branchIndicator" | "branchText" | "branchTrigger" | "itemText" | "nodeCheckbox" | "nodeRenameInput" | "tree">;
9
+ declare const anatomy: AnatomyInstance<"root" | "label" | "item" | "itemText" | "itemIndicator" | "tree" | "branch" | "branchContent" | "branchControl" | "branchIndentGuide" | "branchIndicator" | "branchText" | "branchTrigger" | "nodeCheckbox" | "nodeRenameInput">;
10
10
  //#endregion
11
11
  //#region src/machines/tree-view/tree-view.collection.d.ts
12
12
  declare const collection: {
@@ -1,12 +1,12 @@
1
1
  import { n as AnatomyInstance } from "../../create-anatomy-DHVOqZET.mjs";
2
2
  import { f as TreeCollectionOptions, g as ValuePath, p as TreeNode, s as FilePathTreeNode, u as IndexPath } from "../../types-Df8ZhdY-.mjs";
3
- import { t as TreeCollection } from "../../tree-collection-DYIVkVee.mjs";
3
+ import { t as TreeCollection } from "../../tree-collection-CqXQBHwY.mjs";
4
4
  import { p as Machine, y as Service } from "../../types-DL5AIQk5.mjs";
5
5
  import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BuUzJjaP.mjs";
6
6
  import { n as TypeaheadState } from "../../typeahead-DMSwLv1e.mjs";
7
7
 
8
8
  //#region src/machines/tree-view/tree-view.anatomy.d.ts
9
- declare const anatomy: AnatomyInstance<"root" | "label" | "item" | "itemIndicator" | "branch" | "branchContent" | "branchControl" | "branchIndentGuide" | "branchIndicator" | "branchText" | "branchTrigger" | "itemText" | "nodeCheckbox" | "nodeRenameInput" | "tree">;
9
+ declare const anatomy: AnatomyInstance<"root" | "label" | "item" | "itemText" | "itemIndicator" | "tree" | "branch" | "branchContent" | "branchControl" | "branchIndentGuide" | "branchIndicator" | "branchText" | "branchTrigger" | "nodeCheckbox" | "nodeRenameInput">;
10
10
  //#endregion
11
11
  //#region src/machines/tree-view/tree-view.collection.d.ts
12
12
  declare const collection: {
@@ -1,7 +1,7 @@
1
1
  import { t as createAnatomy } from "../../create-anatomy-CArN8dVu.mjs";
2
2
  import { W as raf, bt as isLeftClick, cn as isEditableElement, ht as isComposingEvent, on as isAnchorElement, ot as setElementValue, pt as getEventTarget, s as getByTypeahead, ut as getEventKey, vn as ariaAttr, xt as isModifierKey, yn as dataAttr } from "../../dom-query-BwpPRIas.mjs";
3
3
  import { At as remove, Dt as partition, Mt as toArray, Nt as uniq, _t as diff, ft as isEqual, mt as addOrRemove, nt as isArray, pt as add, t as ensure, u as createSplitProps, vt as first, wt as last } from "../../utils-DSBXwmDm.mjs";
4
- import { n as filePathToTree, t as TreeCollection } from "../../collection-C85P2ZDW.mjs";
4
+ import { n as filePathToTree, t as TreeCollection } from "../../collection-CjwZd09Z.mjs";
5
5
  import { a as createMachine, i as createGuards } from "../../core-BjksCLhs.mjs";
6
6
  import { t as createProps } from "../../create-props-SRSjdUTq.mjs";
7
7
 
@@ -76,18 +76,21 @@ function connect(service, normalize) {
76
76
  const focusedValue = context.get("focusedValue");
77
77
  const loadingStatus = context.get("loadingStatus");
78
78
  const renamingValue = context.get("renamingValue");
79
+ const skip = ({ indexPath }) => {
80
+ return collection$1.getValuePath(indexPath).slice(0, -1).some((value) => !expandedValue.includes(value));
81
+ };
82
+ const firstNode = collection$1.getFirstNode(void 0, { skip });
83
+ const firstNodeValue = firstNode ? collection$1.getNodeValue(firstNode) : null;
79
84
  function getNodeState(props$1) {
80
85
  const { node, indexPath } = props$1;
81
86
  const value = collection$1.getNodeValue(node);
82
- const firstNode = collection$1.getFirstNode();
83
- const firstNodeValue = firstNode ? collection$1.getNodeValue(firstNode) : null;
84
87
  return {
85
88
  id: getNodeId(scope, value),
86
89
  value,
87
90
  indexPath,
88
91
  valuePath: collection$1.getValuePath(indexPath),
89
92
  disabled: Boolean(node.disabled),
90
- focused: focusedValue == null ? firstNodeValue == value : focusedValue === value,
93
+ focused: focusedValue == null ? firstNodeValue === value : focusedValue === value,
91
94
  selected: selectedValue.includes(value),
92
95
  expanded: expandedValue.includes(value),
93
96
  loading: loadingStatus[value] === "loading",
@@ -971,7 +974,8 @@ const machine = createMachine({
971
974
  focusTreeFirstNode(params) {
972
975
  const { prop, scope } = params;
973
976
  const collection$1 = prop("collection");
974
- const firstNode = collection$1.getFirstNode();
977
+ const firstNode = collection$1.getFirstNode(void 0, { skip: skipFn(params) });
978
+ if (!firstNode) return;
975
979
  const firstValue = collection$1.getNodeValue(firstNode);
976
980
  if (scrollToNode(params, firstValue)) raf(() => focusNode(scope, firstValue));
977
981
  else focusNode(scope, firstValue);
@@ -988,7 +992,8 @@ const machine = createMachine({
988
992
  const { event, prop, scope } = params;
989
993
  const collection$1 = prop("collection");
990
994
  const branchNode = collection$1.findNode(event.id);
991
- const firstNode = collection$1.getFirstNode(branchNode);
995
+ const firstNode = collection$1.getFirstNode(branchNode, { skip: skipFn(params) });
996
+ if (!firstNode) return;
992
997
  const firstValue = collection$1.getNodeValue(firstNode);
993
998
  if (scrollToNode(params, firstValue)) raf(() => focusNode(scope, firstValue));
994
999
  else focusNode(scope, firstValue);
@@ -1,5 +1,5 @@
1
1
  import { r as CollectionOptions, t as CollectionItem } from "./types-Df8ZhdY-.mjs";
2
- import { t as ListCollection } from "./list-collection-BbgocToA.mjs";
2
+ import { t as ListCollection } from "./list-collection-swuCMCIS.mjs";
3
3
 
4
4
  //#region src/shared/collection/grid-collection.d.ts
5
5
  interface GridCollectionOptions<T> extends CollectionOptions<T> {
@@ -1,5 +1,5 @@
1
1
  import { r as CollectionOptions, t as CollectionItem } from "./types-CADkcKtr.cjs";
2
- import { t as ListCollection } from "./list-collection-DettiQL3.cjs";
2
+ import { t as ListCollection } from "./list-collection-BslnP0r-.cjs";
3
3
 
4
4
  //#region src/shared/collection/grid-collection.d.ts
5
5
  interface GridCollectionOptions<T> extends CollectionOptions<T> {
@@ -27,7 +27,7 @@ declare class TreeCollection<T = TreeNode> {
27
27
  getNodeDisabled: (node: T) => boolean;
28
28
  stringify: (value: string) => string | null;
29
29
  stringifyNode: (node: T) => string;
30
- getFirstNode: (rootNode?: T) => T | undefined;
30
+ getFirstNode: (rootNode?: T, opts?: TreeSkipOptions<T>) => T | undefined;
31
31
  getLastNode: (rootNode?: T, opts?: TreeSkipOptions<T>) => T | undefined;
32
32
  at: (indexPath: IndexPath) => T | undefined;
33
33
  findNode: (value: string, rootNode?: T) => T | undefined;
@@ -27,7 +27,7 @@ declare class TreeCollection<T = TreeNode> {
27
27
  getNodeDisabled: (node: T) => boolean;
28
28
  stringify: (value: string) => string | null;
29
29
  stringifyNode: (node: T) => string;
30
- getFirstNode: (rootNode?: T) => T | undefined;
30
+ getFirstNode: (rootNode?: T, opts?: TreeSkipOptions<T>) => T | undefined;
31
31
  getLastNode: (rootNode?: T, opts?: TreeSkipOptions<T>) => T | undefined;
32
32
  at: (indexPath: IndexPath) => T | undefined;
33
33
  findNode: (value: string, rootNode?: T) => T | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprawlify/primitives",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "description": "A set of primitive components for building user interfaces.",
6
6
  "author": "sprawlify <npm@sprawlify.com>",