@hybridly/vue 0.4.2 → 0.4.3

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.
package/dist/index.d.ts CHANGED
@@ -86,7 +86,7 @@ declare const RouterLink: vue.DefineComponent<{
86
86
  default: undefined;
87
87
  };
88
88
  preload: {
89
- type: BooleanConstructor;
89
+ type: PropType<boolean | "hover" | "mount">;
90
90
  default: boolean;
91
91
  };
92
92
  }, (props: _vue_shared.LooseRequired<{
@@ -96,7 +96,7 @@ declare const RouterLink: vue.DefineComponent<{
96
96
  readonly as: string | Record<string, any>;
97
97
  readonly external: boolean;
98
98
  readonly disabled: boolean;
99
- readonly preload: boolean;
99
+ readonly preload: boolean | "hover" | "mount";
100
100
  readonly text?: string | undefined;
101
101
  readonly href?: string | undefined;
102
102
  } & {}>) => vue.VNode<vue.RendererNode, vue.RendererElement, {
@@ -137,7 +137,7 @@ declare const RouterLink: vue.DefineComponent<{
137
137
  default: undefined;
138
138
  };
139
139
  preload: {
140
- type: BooleanConstructor;
140
+ type: PropType<boolean | "hover" | "mount">;
141
141
  default: boolean;
142
142
  };
143
143
  }>>, {
@@ -149,7 +149,7 @@ declare const RouterLink: vue.DefineComponent<{
149
149
  as: string | Record<string, any>;
150
150
  external: boolean;
151
151
  disabled: boolean;
152
- preload: boolean;
152
+ preload: boolean | "hover" | "mount";
153
153
  }, {}>;
154
154
 
155
155
  /** Accesses all current properties. */
@@ -492,6 +492,7 @@ declare function useForm<T extends SearchableObject, P extends Path<T> & string
492
492
  clearError: (key: P) => void;
493
493
  setInitial: (newInitial: Partial<T>) => void;
494
494
  hasDirty: (...keys: P[]) => boolean;
495
+ submitWith: (optionsOverrides?: Omit<HybridRequestOptions$1, 'data'>) => Promise<_hybridly_core.NavigationResponse>;
495
496
  submitWithOptions: (optionsOverrides?: Omit<HybridRequestOptions$1, 'data'>) => Promise<_hybridly_core.NavigationResponse>;
496
497
  submit: () => Promise<_hybridly_core.NavigationResponse>;
497
498
  hasErrors: boolean;
@@ -826,4 +827,4 @@ declare function useRoute(): {
826
827
  matches: <T extends string>(name: MaybeRefOrGetter<T>, parameters?: Record<string, any> | undefined) => boolean;
827
828
  };
828
829
 
829
- export { Layout, RouterLink, defineLayout, defineLayoutProperties, initializeHybridly, registerHook, setProperty, useBackForward, useContext, useDialog, useForm, useHistoryState, usePaginator, useProperties, useProperty, useRefinements, useRoute };
830
+ export { type Layout, RouterLink, defineLayout, defineLayoutProperties, initializeHybridly, registerHook, setProperty, useBackForward, useContext, useDialog, useForm, useHistoryState, usePaginator, useProperties, useProperty, useRefinements, useRoute };
package/dist/index.mjs CHANGED
@@ -218,7 +218,9 @@ function setupDevtools(app) {
218
218
  });
219
219
  const listen = [
220
220
  "start",
221
+ "ready",
221
222
  "data",
223
+ "navigating",
222
224
  "navigated",
223
225
  "progress",
224
226
  "error",
@@ -227,7 +229,9 @@ function setupDevtools(app) {
227
229
  "invalid",
228
230
  "exception",
229
231
  "fail",
230
- "after"
232
+ "after",
233
+ "backForward",
234
+ "success"
231
235
  ];
232
236
  registerHook$1("before", (options) => {
233
237
  const groupId = (Math.random() + 1).toString(36).substring(7);
@@ -404,28 +408,36 @@ Please specify a more appropriate element using the "as" attribute. For example:
404
408
 
405
409
  <RouterLink href="${url}" method="${method}" as="button">...</RouterLink>`);
406
410
  }
411
+ function performPreload(type) {
412
+ if (!preloads) {
413
+ return;
414
+ }
415
+ if (props.external) {
416
+ return;
417
+ }
418
+ if (method !== "GET") {
419
+ return;
420
+ }
421
+ if (type !== "mount" && props.disabled) {
422
+ return;
423
+ }
424
+ if (type === "hover" && preloads === "mount") {
425
+ return;
426
+ }
427
+ if (type === "mount" && preloads !== "mount") {
428
+ return;
429
+ }
430
+ router.preload(url, {
431
+ data,
432
+ ...props.options
433
+ });
434
+ }
435
+ performPreload("mount");
407
436
  return h(props.as, {
408
437
  ...attrs,
409
438
  ...as === "a" ? { href: url } : {},
410
439
  ...props.disabled ? { disabled: props.disabled } : {},
411
- onMouseenter: () => {
412
- if (!preloads) {
413
- return;
414
- }
415
- if (props.external) {
416
- return;
417
- }
418
- if (props.disabled) {
419
- return;
420
- }
421
- if (method !== "GET") {
422
- return;
423
- }
424
- router.preload(url, {
425
- data,
426
- ...props.options
427
- });
428
- },
440
+ onMouseenter: () => performPreload("hover"),
429
441
  onClick: (event) => {
430
442
  if (props.external) {
431
443
  return;
@@ -484,7 +496,7 @@ Please specify a more appropriate element using the "as" attribute. For example:
484
496
  default: void 0
485
497
  },
486
498
  preload: {
487
- type: Boolean,
499
+ type: [Boolean, String],
488
500
  default: false
489
501
  }
490
502
  }
@@ -690,6 +702,8 @@ function useForm(options) {
690
702
  clearError,
691
703
  setInitial,
692
704
  hasDirty,
705
+ submitWith: submit,
706
+ /** @deprecated Use `submitWith` instead */
693
707
  submitWithOptions: submit,
694
708
  submit: () => submit(),
695
709
  hasErrors: computed(() => Object.values(errors.value ?? {}).length > 0),
@@ -781,10 +795,15 @@ const registerHook = (hook, fn, options) => {
781
795
 
782
796
  function useDialog() {
783
797
  return {
798
+ /** Closes the dialog. */
784
799
  close: () => router$1.dialog.close(),
800
+ /** Closes the dialog without a server round-trip. */
785
801
  closeLocally: () => router$1.dialog.close({ local: true }),
802
+ /** Unmounts the dialog. Should be called after its closing animations. */
786
803
  unmount: () => dialogStore.removeComponent(),
804
+ /** Whether the dialog is shown. */
787
805
  show: computed(() => dialogStore.state.show.value),
806
+ /** Properties of the dialog. */
788
807
  properties: computed(() => state.context.value?.dialog?.properties)
789
808
  };
790
809
  }
@@ -905,20 +924,65 @@ function useRefinements(properties, refinementsKeys, defaultOptions = {}) {
905
924
  return _ref;
906
925
  }
907
926
  return {
927
+ /**
928
+ * Binds a named filter to a ref, applying filters when it changes and updating the ref accordingly.
929
+ */
908
930
  bindFilter,
931
+ /**
932
+ * Available filters.
933
+ */
909
934
  filters: toReactive(refinements.value.filters),
935
+ /**
936
+ * Available sorts.
937
+ */
910
938
  sorts: toReactive(refinements.value.sorts),
939
+ /**
940
+ * Gets a filter by name.
941
+ */
911
942
  getFilter,
943
+ /**
944
+ * Gets a sort by name.
945
+ */
912
946
  getSort,
947
+ /**
948
+ * Resets all filters and sorts.
949
+ */
913
950
  reset,
951
+ /**
952
+ * Toggles the specified sort.
953
+ */
914
954
  toggleSort,
955
+ /**
956
+ * Whether a sort is active.
957
+ */
915
958
  isSorting,
959
+ /**
960
+ * Whether a filter is active.
961
+ */
916
962
  isFiltering,
963
+ /**
964
+ * The current sorts.
965
+ */
917
966
  currentSorts,
967
+ /**
968
+ * The current filters.
969
+ */
918
970
  currentFilters,
971
+ /**
972
+ * Clears the given filter.
973
+ */
919
974
  clearFilter,
975
+ /**
976
+ * Resets all sorts.
977
+ */
920
978
  clearSorts,
979
+ /**
980
+ * Resets all filters.
981
+ */
921
982
  clearFilters,
983
+ /**
984
+ * Applies the given filter.
985
+ */
922
986
  applyFilter
923
987
  };
924
988
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridly/vue",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Vue adapter for Hybridly",
5
5
  "keywords": [
6
6
  "hybridly",
@@ -44,12 +44,12 @@
44
44
  "lodash.isequal": "^4.5.0",
45
45
  "nprogress": "^0.2.0",
46
46
  "qs": "^6.11.2",
47
- "@hybridly/core": "0.4.2",
48
- "@hybridly/progress-plugin": "0.4.2",
49
- "@hybridly/utils": "0.4.2"
47
+ "@hybridly/core": "0.4.3",
48
+ "@hybridly/progress-plugin": "0.4.3",
49
+ "@hybridly/utils": "0.4.3"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/lodash": "^4.14.195",
52
+ "@types/lodash": "^4.14.197",
53
53
  "@types/lodash.clonedeep": "^4.5.7",
54
54
  "@types/lodash.isequal": "^4.5.6",
55
55
  "@types/nprogress": "^0.2.0",