@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.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const vue = require('vue');
6
4
  const core = require('@hybridly/core');
7
5
  const utils = require('@hybridly/utils');
@@ -12,10 +10,10 @@ const dotDiver = require('@clickbar/dot-diver');
12
10
  const isEqual = require('lodash.isequal');
13
11
  const hybridly = require('hybridly');
14
12
 
15
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
13
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
16
14
 
17
- const qs__default = /*#__PURE__*/_interopDefaultLegacy(qs);
18
- const isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
15
+ const qs__default = /*#__PURE__*/_interopDefaultCompat(qs);
16
+ const isEqual__default = /*#__PURE__*/_interopDefaultCompat(isEqual);
19
17
 
20
18
  const DEBUG_KEY = "vue:state:dialog";
21
19
  const dialogStore = {
@@ -226,7 +224,9 @@ function setupDevtools(app) {
226
224
  });
227
225
  const listen = [
228
226
  "start",
227
+ "ready",
229
228
  "data",
229
+ "navigating",
230
230
  "navigated",
231
231
  "progress",
232
232
  "error",
@@ -235,7 +235,9 @@ function setupDevtools(app) {
235
235
  "invalid",
236
236
  "exception",
237
237
  "fail",
238
- "after"
238
+ "after",
239
+ "backForward",
240
+ "success"
239
241
  ];
240
242
  core.registerHook("before", (options) => {
241
243
  const groupId = (Math.random() + 1).toString(36).substring(7);
@@ -412,28 +414,36 @@ Please specify a more appropriate element using the "as" attribute. For example:
412
414
 
413
415
  <RouterLink href="${url}" method="${method}" as="button">...</RouterLink>`);
414
416
  }
417
+ function performPreload(type) {
418
+ if (!preloads) {
419
+ return;
420
+ }
421
+ if (props.external) {
422
+ return;
423
+ }
424
+ if (method !== "GET") {
425
+ return;
426
+ }
427
+ if (type !== "mount" && props.disabled) {
428
+ return;
429
+ }
430
+ if (type === "hover" && preloads === "mount") {
431
+ return;
432
+ }
433
+ if (type === "mount" && preloads !== "mount") {
434
+ return;
435
+ }
436
+ core.router.preload(url, {
437
+ data,
438
+ ...props.options
439
+ });
440
+ }
441
+ performPreload("mount");
415
442
  return vue.h(props.as, {
416
443
  ...attrs,
417
444
  ...as === "a" ? { href: url } : {},
418
445
  ...props.disabled ? { disabled: props.disabled } : {},
419
- onMouseenter: () => {
420
- if (!preloads) {
421
- return;
422
- }
423
- if (props.external) {
424
- return;
425
- }
426
- if (props.disabled) {
427
- return;
428
- }
429
- if (method !== "GET") {
430
- return;
431
- }
432
- core.router.preload(url, {
433
- data,
434
- ...props.options
435
- });
436
- },
446
+ onMouseenter: () => performPreload("hover"),
437
447
  onClick: (event) => {
438
448
  if (props.external) {
439
449
  return;
@@ -492,7 +502,7 @@ Please specify a more appropriate element using the "as" attribute. For example:
492
502
  default: void 0
493
503
  },
494
504
  preload: {
495
- type: Boolean,
505
+ type: [Boolean, String],
496
506
  default: false
497
507
  }
498
508
  }
@@ -698,6 +708,8 @@ function useForm(options) {
698
708
  clearError,
699
709
  setInitial,
700
710
  hasDirty,
711
+ submitWith: submit,
712
+ /** @deprecated Use `submitWith` instead */
701
713
  submitWithOptions: submit,
702
714
  submit: () => submit(),
703
715
  hasErrors: vue.computed(() => Object.values(errors.value ?? {}).length > 0),
@@ -789,10 +801,15 @@ const registerHook = (hook, fn, options) => {
789
801
 
790
802
  function useDialog() {
791
803
  return {
804
+ /** Closes the dialog. */
792
805
  close: () => hybridly.router.dialog.close(),
806
+ /** Closes the dialog without a server round-trip. */
793
807
  closeLocally: () => hybridly.router.dialog.close({ local: true }),
808
+ /** Unmounts the dialog. Should be called after its closing animations. */
794
809
  unmount: () => dialogStore.removeComponent(),
810
+ /** Whether the dialog is shown. */
795
811
  show: vue.computed(() => dialogStore.state.show.value),
812
+ /** Properties of the dialog. */
796
813
  properties: vue.computed(() => state.context.value?.dialog?.properties)
797
814
  };
798
815
  }
@@ -913,20 +930,65 @@ function useRefinements(properties, refinementsKeys, defaultOptions = {}) {
913
930
  return _ref;
914
931
  }
915
932
  return {
933
+ /**
934
+ * Binds a named filter to a ref, applying filters when it changes and updating the ref accordingly.
935
+ */
916
936
  bindFilter,
937
+ /**
938
+ * Available filters.
939
+ */
917
940
  filters: toReactive(refinements.value.filters),
941
+ /**
942
+ * Available sorts.
943
+ */
918
944
  sorts: toReactive(refinements.value.sorts),
945
+ /**
946
+ * Gets a filter by name.
947
+ */
919
948
  getFilter,
949
+ /**
950
+ * Gets a sort by name.
951
+ */
920
952
  getSort,
953
+ /**
954
+ * Resets all filters and sorts.
955
+ */
921
956
  reset,
957
+ /**
958
+ * Toggles the specified sort.
959
+ */
922
960
  toggleSort,
961
+ /**
962
+ * Whether a sort is active.
963
+ */
923
964
  isSorting,
965
+ /**
966
+ * Whether a filter is active.
967
+ */
924
968
  isFiltering,
969
+ /**
970
+ * The current sorts.
971
+ */
925
972
  currentSorts,
973
+ /**
974
+ * The current filters.
975
+ */
926
976
  currentFilters,
977
+ /**
978
+ * Clears the given filter.
979
+ */
927
980
  clearFilter,
981
+ /**
982
+ * Resets all sorts.
983
+ */
928
984
  clearSorts,
985
+ /**
986
+ * Resets all filters.
987
+ */
929
988
  clearFilters,
989
+ /**
990
+ * Applies the given filter.
991
+ */
930
992
  applyFilter
931
993
  };
932
994
  }