@hybridly/vue 0.10.0-beta.2 → 0.10.0-beta.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.mts CHANGED
@@ -3,7 +3,6 @@ import { App, ComputedRef, DeepReadonly, DefineComponent, MaybeRefOrGetter, Plug
3
3
  import { GlobalHybridlyProperties, HybridRequestOptions, Method, Plugin as Plugin$1, Progress, RouteName, RouteParameters, RouterContext, RouterContextOptions, UrlResolvable, can, registerHook as registerHook$1, route, router } from "@hybridly/core";
4
4
  import { FormDataConvertible, RequestData } from "@hybridly/utils";
5
5
  import { Path, PathValue, SearchableObject } from "@clickbar/dot-diver";
6
- import { Axios } from "axios";
7
6
 
8
7
  //#region ../hybridly/src/index.d.ts
9
8
 
@@ -48,7 +47,7 @@ type InternalProperties = GlobalHybridlyProperties & {
48
47
  /** Accesses all current properties. */
49
48
  declare function useProperties<T extends object, Global extends InternalProperties = InternalProperties>(): vue0.DeepReadonly<vue0.UnwrapNestedRefs<T & Global>>;
50
49
  /** Accesses a property with a dot notation. */
51
- declare function useProperty<Override = never, T extends SearchableObject = GlobalHybridlyProperties, P extends Path<T> & string = Path<T> & string, ReturnType$1 = ([Override] extends [never] ? PathValue<T, P> : Override)>(path: [Override] extends [never] ? P : string): ComputedRef<ReturnType$1>;
50
+ declare function useProperty<Override = never, T extends SearchableObject = GlobalHybridlyProperties, P extends Path<T> & string = Path<T> & string, ReturnType = ([Override] extends [never] ? PathValue<T, P> : Override)>(path: [Override] extends [never] ? P : string): ComputedRef<ReturnType>;
52
51
  /**
53
52
  * Sets the property at the given path to the given value.
54
53
  * Note: this helper is experimental and may change in the future.
@@ -224,15 +223,10 @@ type Properties = Record<string | number, Property>;
224
223
  * Exposes utilities related to the dialogs.
225
224
  */
226
225
  declare function useDialog(): {
227
- /** Closes the dialog. */
228
- close: () => void;
229
- /** Closes the dialog without a server round-trip. */
230
- closeLocally: () => void;
231
- /** Unmounts the dialog. Should be called after its closing animations. */
232
- unmount: () => void;
233
- /** Whether the dialog is shown. */
234
- show: vue0.WritableComputedRef<boolean | undefined, boolean | undefined>;
235
- /** Properties of the dialog. */
226
+ /** Closes the dialog. */close: () => void; /** Closes the dialog without a server round-trip. */
227
+ closeLocally: () => void; /** Unmounts the dialog. Should be called after its closing animations. */
228
+ unmount: () => void; /** Whether the dialog is shown. */
229
+ show: vue0.WritableComputedRef<boolean | undefined, boolean | undefined>; /** Properties of the dialog. */
236
230
  properties: vue0.ComputedRef<Properties | undefined>;
237
231
  };
238
232
  //#endregion
@@ -366,7 +360,7 @@ declare global {
366
360
  };
367
361
  }
368
362
  }
369
- declare function useRefinements<Properties$1 extends object, RefinementsKey extends { [K in keyof Properties$1]: Properties$1[K] extends Refinements ? K : never }[keyof Properties$1]>(properties: Properties$1, refinementsKeys: RefinementsKey, defaultOptions?: AvailableHybridRequestOptions): {
363
+ declare function useRefinements<Properties extends object, RefinementsKey extends { [K in keyof Properties]: Properties[K] extends Refinements ? K : never }[keyof Properties]>(properties: Properties, refinementsKeys: RefinementsKey, defaultOptions?: AvailableHybridRequestOptions): {
370
364
  /**
371
365
  * Binds a named filter to a ref, applying filters when it changes and updating the ref accordingly.
372
366
  */
@@ -681,87 +675,51 @@ declare function useTable<RecordType extends (Props[PropsKey] extends Table<infe
681
675
  select: (record: RecordTypeWithExtra) => void;
682
676
  deselect: (record: RecordTypeWithExtra) => void;
683
677
  inlineActions: {
684
- /** The name of this action. */
685
- name: string;
686
- /** The label of this action. */
687
- label: string;
688
- /** The type of this action. */
689
- type: string;
690
- /** Custom metadata for this action. */
691
- metadata: any;
692
- /** Executes the action. */
678
+ /** The name of this action. */name: string; /** The label of this action. */
679
+ label: string; /** The type of this action. */
680
+ type: string; /** Custom metadata for this action. */
681
+ metadata: any; /** Executes the action. */
693
682
  execute: (record: RecordTypeWithExtra | RecordIdentifier) => Promise<index_d_exports.NavigationResponse>;
694
683
  }[];
695
684
  bulkActions: {
696
- /** Should deselect all records after action. */
697
- deselect: boolean;
698
- /** The name of this action. */
699
- name: string;
700
- /** The label of this action. */
701
- label: string;
702
- /** The type of this action. */
703
- type: string;
704
- /** Custom metadata for this action. */
705
- metadata: any;
706
- /** Executes the action. */
685
+ /** Should deselect all records after action. */deselect: boolean; /** The name of this action. */
686
+ name: string; /** The label of this action. */
687
+ label: string; /** The type of this action. */
688
+ type: string; /** Custom metadata for this action. */
689
+ metadata: any; /** Executes the action. */
707
690
  execute: (options?: BulkActionOptions) => Promise<index_d_exports.NavigationResponse>;
708
691
  }[];
709
692
  executeInlineAction: (action: Action | string, record: RecordTypeWithExtra | RecordIdentifier) => Promise<index_d_exports.NavigationResponse>;
710
693
  executeBulkAction: (action: Action | string, options?: BulkActionOptions) => Promise<index_d_exports.NavigationResponse>;
711
694
  columns: {
712
- /** Toggles sorting for this column. */
713
- toggleSort: (options?: ToggleSortOptions) => Promise<index_d_exports.NavigationResponse | undefined>;
714
- /** Checks whether the column is being sorted. */
715
- isSorting: (direction?: SortDirection) => boolean;
716
- /** Applies the filer for this column. */
717
- applyFilter: (value: any, options?: AvailableHybridRequestOptions) => Promise<index_d_exports.NavigationResponse | undefined>;
718
- /** Clears the filter for this column. */
719
- clearFilter: (options?: AvailableHybridRequestOptions) => Promise<index_d_exports.NavigationResponse>;
720
- /** Checks whether the column is sortable. */
721
- isSortable: boolean;
722
- /** Checks whether the column is filterable. */
723
- isFilterable: boolean;
724
- /** The name of this column. */
725
- name: keyof RecordTypeWithExtra;
726
- /** The label of this column. */
727
- label: string;
728
- /** The type of this column. */
729
- type: string;
730
- /** Metadata of this column. */
695
+ /** Toggles sorting for this column. */toggleSort: (options?: ToggleSortOptions) => Promise<index_d_exports.NavigationResponse | undefined>; /** Checks whether the column is being sorted. */
696
+ isSorting: (direction?: SortDirection) => boolean; /** Applies the filer for this column. */
697
+ applyFilter: (value: any, options?: AvailableHybridRequestOptions) => Promise<index_d_exports.NavigationResponse | undefined>; /** Clears the filter for this column. */
698
+ clearFilter: (options?: AvailableHybridRequestOptions) => Promise<index_d_exports.NavigationResponse>; /** Checks whether the column is sortable. */
699
+ isSortable: boolean; /** Checks whether the column is filterable. */
700
+ isFilterable: boolean; /** The name of this column. */
701
+ name: keyof RecordTypeWithExtra; /** The label of this column. */
702
+ label: string; /** The type of this column. */
703
+ type: string; /** Metadata of this column. */
731
704
  metadata: Record<string, any>;
732
705
  }[];
733
706
  data: RecordType[];
734
707
  records: {
735
- /** The actual record. */
736
- record: any[];
737
- /** The key of the record. Use this instead of `id`. */
738
- key: RecordIdentifier;
739
- /** Executes the given inline action. */
740
- execute: (action: string | InlineAction) => Promise<index_d_exports.NavigationResponse>;
741
- /** Gets the available inline actions. */
708
+ /** The actual record. */record: any[]; /** The key of the record. Use this instead of `id`. */
709
+ key: RecordIdentifier; /** Executes the given inline action. */
710
+ execute: (action: string | InlineAction) => Promise<index_d_exports.NavigationResponse>; /** Gets the available inline actions. */
742
711
  actions: {
743
- /** Executes the action. */
744
- execute: () => Promise<index_d_exports.NavigationResponse>;
745
- /** The name of this action. */
746
- name: string;
747
- /** The label of this action. */
748
- label: string;
749
- /** The type of this action. */
750
- type: string;
751
- /** Custom metadata for this action. */
712
+ /** Executes the action. */execute: () => Promise<index_d_exports.NavigationResponse>; /** The name of this action. */
713
+ name: string; /** The label of this action. */
714
+ label: string; /** The type of this action. */
715
+ type: string; /** Custom metadata for this action. */
752
716
  metadata: any;
753
- }[];
754
- /** Selects this record. */
755
- select: () => void;
756
- /** Deselects this record. */
757
- deselect: () => void;
758
- /** Toggles the selection for this record. */
759
- toggle: (force?: boolean) => void;
760
- /** Checks whether this record is selected. */
761
- selected: boolean;
762
- /** Gets the value of the record for the specified column. */
763
- value: (column: string | Column<RecordTypeWithExtra>) => RecordType[string] | RecordType[number] | RecordType[symbol];
764
- /** Gets the extra object of the record for the specified column. */
717
+ }[]; /** Selects this record. */
718
+ select: () => void; /** Deselects this record. */
719
+ deselect: () => void; /** Toggles the selection for this record. */
720
+ toggle: (force?: boolean) => void; /** Checks whether this record is selected. */
721
+ selected: boolean; /** Gets the value of the record for the specified column. */
722
+ value: (column: string | Column<RecordTypeWithExtra>) => RecordType[string] | RecordType[number] | RecordType[symbol]; /** Gets the extra object of the record for the specified column. */
765
723
  extra: (column: string | Column<RecordTypeWithExtra>, path: string) => any;
766
724
  }[];
767
725
  paginator: PaginatorResult<unknown, Omit<PaginatorKindName extends "cursor" ? CursorPaginator<RecordTypeWithExtra> : PaginatorKindName extends "simple" ? SimplePaginator<RecordTypeWithExtra> : Paginator<RecordTypeWithExtra>, "data">>;
@@ -812,7 +770,9 @@ declare function initializeHybridly(options?: InitializeOptions): Promise<any>;
812
770
  interface InitializeOptions {
813
771
  /** Callback that gets executed before Vue is mounted. */
814
772
  enhanceVue?: (/** Vue application to enhance. */
773
+
815
774
  vue: App<Element>, /** Initial payload. */
775
+
816
776
  payload: Record<string, any>) => any;
817
777
  /** ID of the app element. */
818
778
  id?: string;
package/dist/index.mjs CHANGED
@@ -44,8 +44,8 @@ function progress(options) {
44
44
  clearTimeout(timeout);
45
45
  timeout = setTimeout(() => startProgress(), resolved.delay);
46
46
  },
47
- progress: (progress$1) => {
48
- if (nprogress.isStarted() && progress$1.percentage) nprogress.set(Math.max(nprogress.status, progress$1.percentage / 100 * .9));
47
+ progress: (progress) => {
48
+ if (nprogress.isStarted() && progress.percentage) nprogress.set(Math.max(nprogress.status, progress.percentage / 100 * .9));
49
49
  },
50
50
  after: () => finishProgress()
51
51
  });
@@ -429,18 +429,18 @@ async function initializeHybridly(options = {}) {
429
429
  onContextUpdate: (context) => {
430
430
  state.setContext(context);
431
431
  },
432
- onViewSwap: async (options$1) => {
433
- if (options$1.component) {
434
- onMountedCallbacks.push(() => options$1.onMounted?.({ isDialog: false }));
435
- state.setView(options$1.component);
432
+ onViewSwap: async (options) => {
433
+ if (options.component) {
434
+ onMountedCallbacks.push(() => options.onMounted?.({ isDialog: false }));
435
+ state.setView(options.component);
436
436
  }
437
- state.setProperties(options$1.properties);
438
- if (!options$1.preserveState && !options$1.dialog) state.setViewKey(random());
439
- if (options$1.dialog) {
440
- onMountedCallbacks.push(() => options$1.onMounted?.({ isDialog: true }));
441
- dialogStore.setComponent(await resolve(options$1.dialog.component));
442
- dialogStore.setProperties(options$1.dialog.properties);
443
- dialogStore.setKey(options$1.dialog.key);
437
+ state.setProperties(options.properties);
438
+ if (!options.preserveState && !options.dialog) state.setViewKey(random());
439
+ if (options.dialog) {
440
+ onMountedCallbacks.push(() => options.onMounted?.({ isDialog: true }));
441
+ dialogStore.setComponent(await resolve(options.dialog.component));
442
+ dialogStore.setProperties(options.dialog.properties);
443
+ dialogStore.setKey(options.dialog.key);
444
444
  dialogStore.show();
445
445
  } else dialogStore.hide();
446
446
  }
@@ -497,7 +497,7 @@ function prepare(options) {
497
497
  async function resolveViewComponent(name, options) {
498
498
  const components = options.imported;
499
499
  const result = options.components.views.find((view) => name === view.identifier);
500
- const path = Object.keys(components).sort((a, b) => a.length - b.length).find((path$1) => result ? path$1.endsWith(result?.path) : false);
500
+ const path = Object.keys(components).sort((a, b) => a.length - b.length).find((path) => result ? path.endsWith(result?.path) : false);
501
501
  if (!result || !path) {
502
502
  console.warn(`View component [${name}] not found. Available components: `, options.components.views.map(({ identifier }) => identifier));
503
503
  showViewComponentErrorModal(name);
@@ -717,7 +717,7 @@ function useForm(options) {
717
717
  /** Whether the submission is being processed. */
718
718
  const processing = ref(false);
719
719
  /** The current request's progress. */
720
- const progress$1 = ref();
720
+ const progress = ref();
721
721
  /**
722
722
  * Sets new initial values for the form, so subsequent resets will use thse values.
723
723
  */
@@ -736,7 +736,7 @@ function useForm(options) {
736
736
  recentlySuccessful.value = false;
737
737
  clearTimeout(timeoutIds.recentlySuccessful);
738
738
  clearTimeout(timeoutIds.recentlyFailed);
739
- progress$1.value = void 0;
739
+ progress.value = void 0;
740
740
  }
741
741
  /**
742
742
  * Resets the fields, errors and submission state.
@@ -791,7 +791,7 @@ function useForm(options) {
791
791
  return hooks.start?.(context);
792
792
  },
793
793
  progress: (incoming, context) => {
794
- progress$1.value = incoming;
794
+ progress.value = incoming;
795
795
  return hooks.progress?.(incoming, context);
796
796
  },
797
797
  error: (incoming, context) => {
@@ -811,7 +811,7 @@ function useForm(options) {
811
811
  return hooks.success?.(payload, context);
812
812
  },
813
813
  after: (context) => {
814
- progress$1.value = void 0;
814
+ progress.value = void 0;
815
815
  processing.value = false;
816
816
  return hooks.after?.(context);
817
817
  }
@@ -887,7 +887,7 @@ function useForm(options) {
887
887
  hasErrors: computed(() => Object.values(errors.value ?? {}).length > 0),
888
888
  initial,
889
889
  loaded,
890
- progress: progress$1,
890
+ progress,
891
891
  isDirty,
892
892
  errors,
893
893
  processing,
@@ -906,8 +906,8 @@ function useForm(options) {
906
906
  */
907
907
  function useHistoryState(key, initial) {
908
908
  const value = ref(router$1.history.get(key) ?? initial);
909
- watch(value, (value$1) => {
910
- router$1.history.remember(key, toRaw(value$1));
909
+ watch(value, (value) => {
910
+ router$1.history.remember(key, toRaw(value));
911
911
  }, {
912
912
  immediate: true,
913
913
  deep: true
@@ -919,8 +919,8 @@ function useHistoryState(key, initial) {
919
919
  //#region src/composables/back-forward.ts
920
920
  function useBackForward(options) {
921
921
  const callbacks = [];
922
- registerHook$1("navigated", (options$1) => {
923
- if (options$1.type === "back-forward") {
922
+ registerHook$1("navigated", (options) => {
923
+ if (options.type === "back-forward") {
924
924
  callbacks.forEach((fn) => fn(state.context.value));
925
925
  callbacks.splice(0, callbacks.length);
926
926
  }
@@ -934,8 +934,8 @@ function useBackForward(options) {
934
934
  /**
935
935
  * Reloads the page on back-forward navigations.
936
936
  */
937
- function reloadOnBackForward(options$1) {
938
- onBackForward(() => router$1.reload(options$1));
937
+ function reloadOnBackForward(options) {
938
+ onBackForward(() => router$1.reload(options));
939
939
  }
940
940
  if (options?.reload) reloadOnBackForward(options.reload === true ? void 0 : options.reload);
941
941
  return {
@@ -945,10 +945,10 @@ function useBackForward(options) {
945
945
  }
946
946
 
947
947
  //#endregion
948
- //#region ../hybridly/dist/index.mjs
949
- var dist_exports = {};
948
+ //#region ../hybridly/src/index.ts
949
+ var src_exports = {};
950
950
  import * as import__hybridly_core from "@hybridly/core";
951
- __reExport(dist_exports, import__hybridly_core);
951
+ __reExport(src_exports, import__hybridly_core);
952
952
 
953
953
  //#endregion
954
954
  //#region src/composables/paginator.ts
@@ -960,7 +960,7 @@ function createPaginator(paginator, options) {
960
960
  ...paginator,
961
961
  to: (page) => {
962
962
  const link = paginator.links.find((l) => l.page === page);
963
- if (link?.url) return dist_exports.router.get(link.url, options);
963
+ if (link?.url) return src_exports.router.get(link.url, options);
964
964
  }
965
965
  };
966
966
  return paginator;
@@ -1257,20 +1257,20 @@ function useBulkSelect() {
1257
1257
  * @see https://hybridly.dev/api/utils/use-query-parameters.html
1258
1258
  */
1259
1259
  function useQueryParameters() {
1260
- const state$1 = reactive({});
1260
+ const state = reactive({});
1261
1261
  function updateState() {
1262
1262
  const params = new URLSearchParams(window.location.search);
1263
- const unusedKeys = new Set(Object.keys(state$1));
1263
+ const unusedKeys = new Set(Object.keys(state));
1264
1264
  for (const key of params.keys()) {
1265
1265
  const paramsForKey = params.getAll(key);
1266
- state$1[key] = paramsForKey.length > 1 ? paramsForKey : params.get(key) || "";
1266
+ state[key] = paramsForKey.length > 1 ? paramsForKey : params.get(key) || "";
1267
1267
  unusedKeys.delete(key);
1268
1268
  }
1269
- Array.from(unusedKeys).forEach((key) => delete state$1[key]);
1269
+ Array.from(unusedKeys).forEach((key) => delete state[key]);
1270
1270
  }
1271
1271
  updateState();
1272
1272
  registerHook$1("navigated", updateState);
1273
- return state$1;
1273
+ return state;
1274
1274
  }
1275
1275
  /**
1276
1276
  * Makes the specified query parameter reactive.
@@ -1279,13 +1279,13 @@ function useQueryParameters() {
1279
1279
  */
1280
1280
  function useQueryParameter(name, options = {}) {
1281
1281
  const query = useQueryParameters();
1282
- const transform = (value$1) => {
1283
- if (options.transform === "bool") return value$1 === true || value$1 === "true" || value$1 === "1" || value$1 === "yes";
1284
- else if (options.transform === "number") return Number(value$1);
1285
- else if (options.transform === "string") return String(value$1);
1286
- else if (options.transform === "date") return new Date(value$1);
1287
- else if (typeof options.transform === "function") return options.transform(value$1);
1288
- return value$1;
1282
+ const transform = (value) => {
1283
+ if (options.transform === "bool") return value === true || value === "true" || value === "1" || value === "yes";
1284
+ else if (options.transform === "number") return Number(value);
1285
+ else if (options.transform === "string") return String(value);
1286
+ else if (options.transform === "date") return new Date(value);
1287
+ else if (typeof options.transform === "function") return options.transform(value);
1288
+ return value;
1289
1289
  };
1290
1290
  const value = ref();
1291
1291
  watch(query, () => {
@@ -1382,7 +1382,7 @@ function useTable(props, key, defaultOptions = {}) {
1382
1382
  isSelected: (record) => bulk.selected(getRecordKey(record)),
1383
1383
  allSelected: bulk.allSelected,
1384
1384
  selection: bulk.selection,
1385
- bindCheckbox: (key$1) => bulk.bindCheckbox(key$1),
1385
+ bindCheckbox: (key) => bulk.bindCheckbox(key),
1386
1386
  toggle: (record) => bulk.toggle(getRecordKey(record)),
1387
1387
  select: (record) => bulk.select(getRecordKey(record)),
1388
1388
  deselect: (record) => bulk.deselect(getRecordKey(record)),
@@ -1406,10 +1406,10 @@ function useTable(props, key, defaultOptions = {}) {
1406
1406
  isFilterable: !!refinements.filters.find((filters) => filters.name === column.name)
1407
1407
  }))),
1408
1408
  data: computed(() => table.value.records.map((record) => {
1409
- return Object.fromEntries(Object.entries(record).map(([key$1, value]) => [key$1, value.value]).filter(([key$1]) => key$1 === "__hybridId"));
1409
+ return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, value.value]).filter(([key]) => key === "__hybridId"));
1410
1410
  })),
1411
1411
  records: computed(() => table.value.records.map((record) => ({
1412
- record: Object.values(record).map((record$1) => record$1.value),
1412
+ record: Object.values(record).map((record) => record.value),
1413
1413
  key: getRecordKey(record),
1414
1414
  execute: (action) => executeInlineAction(getActionName(action), getRecordKey(record)),
1415
1415
  actions: table.value.inlineActions.map((action) => ({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridly/vue",
3
3
  "type": "module",
4
- "version": "0.10.0-beta.2",
4
+ "version": "0.10.0-beta.3",
5
5
  "description": "Vue adapter for Hybridly",
6
6
  "author": "Enzo Innocenzi <enzo@innocenzi.dev>",
7
7
  "license": "MIT",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@clickbar/dot-diver": "^1.0.7",
49
- "@hybridly/core": "0.10.0-beta.1",
50
- "@hybridly/utils": "0.10.0-beta.1",
49
+ "@hybridly/core": "0.10.0-beta.3",
50
+ "@hybridly/utils": "0.10.0-beta.3",
51
51
  "@vue/devtools-api": "^7.7.6",
52
52
  "defu": "^6.1.4",
53
53
  "lodash.isequal": "^4.5.0",