@chelone/vue 0.1.0 → 0.2.0

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.
@@ -4,7 +4,7 @@ import { useRoute, useRouter, START_LOCATION } from "vue-router";
4
4
  import _sfc_main$6 from "../components/admin/layout/layout.vue.js";
5
5
  import _sfc_main$1 from "../components/admin/layout/theme-provider.vue.js";
6
6
  import _sfc_main$4 from "../components/admin/auth/login-page.vue.js";
7
- import _sfc_main$3 from "../components/ui/spinner2.vue.js";
7
+ import _sfc_main$3 from "../components/ui/spinner.vue.js";
8
8
  import { useBasename } from "../router/adapter.js";
9
9
  import { useWatchDataErrors } from "../auth/permissions-hooks.js";
10
10
  import { useAuthGate } from "./auth-gate.js";
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, provide, useSlots, onScopeDispose, onBeforeUpdate, watchEffect, openBlock, createElementBlock, Fragment, renderSlot, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps } from "vue";
2
- import { joinBasename } from "@chelone/core";
2
+ import { createI18n, englishMessages, joinBasename } from "@chelone/core";
3
3
  import { BasenameKey } from "../router/adapter.js";
4
4
  import { QueryClient, VUE_QUERY_CLIENT } from "@tanstack/vue-query";
5
5
  import { useRouter, START_LOCATION } from "vue-router";
@@ -44,7 +44,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
44
44
  dataProvider: props.dataProvider,
45
45
  queryClient,
46
46
  authProvider: props.authProvider,
47
- i18n: props.i18n,
47
+ // Built once, and only when the app brings no i18n of its own.
48
+ i18n: props.i18n ?? createI18n({ locale: "en", messages: { en: englishMessages } }),
48
49
  store: props.store,
49
50
  notifications: props.notifications,
50
51
  // Thread the zod registry so `useForm({ resource })` auto-resolves the
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, unref, openBlock, createBlock, createElementBlock, createVNode } from "vue";
2
2
  import { useHandleAuthCallback } from "../../../admin/auth-gate.js";
3
- import _sfc_main$2 from "../../ui/spinner2.vue.js";
3
+ import _sfc_main$2 from "../../ui/spinner.vue.js";
4
4
  import _sfc_main$1 from "./auth-error.vue.js";
5
5
  const _hoisted_1 = {
6
6
  key: 1,
@@ -6,7 +6,7 @@ import { useTranslate } from "../../../i18n/use-translate.js";
6
6
  import { cn } from "../../../lib/utils.js";
7
7
  import { useLogin } from "../../../auth/auth-hooks.js";
8
8
  import _sfc_main$2 from "../../ui/button.vue.js";
9
- import _sfc_main$3 from "../../ui/spinner2.vue.js";
9
+ import _sfc_main$3 from "../../ui/spinner.vue.js";
10
10
  import _sfc_main$1 from "../inputs/text-input.vue.js";
11
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  __name: "login-form",
@@ -6,7 +6,7 @@ import { useForm } from "../../../form/use-form.js";
6
6
  import { useTranslate } from "../../../i18n/use-translate.js";
7
7
  import { cn } from "../../../lib/utils.js";
8
8
  import _sfc_main$3 from "../../ui/button.vue.js";
9
- import _sfc_main$4 from "../../ui/spinner2.vue.js";
9
+ import _sfc_main$4 from "../../ui/spinner.vue.js";
10
10
  import _sfc_main$2 from "../inputs/password-input.vue.js";
11
11
  import _sfc_main$1 from "../inputs/text-input.vue.js";
12
12
  import { LogInIcon } from "./icons.js";
@@ -3,6 +3,8 @@ import { removeRecordsFromCache } from "@chelone/core";
3
3
  import { useCheloneContext } from "../../../context.js";
4
4
  import { useUndoable } from "../../../data/undoable.js";
5
5
  import { useTranslate } from "../../../i18n/use-translate.js";
6
+ import { humanize, pluralize } from "../../../label/inflection.js";
7
+ import { useGetRecordRepresentation } from "../../../label/use-get-record-representation.js";
6
8
  import { RecordContextKey } from "../../../record/record-context.js";
7
9
  import { useResourceContext } from "../../../resource-context.js";
8
10
  import { useMenuAccess } from "../layout/use-menu-access.js";
@@ -56,6 +58,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
58
  }))
57
59
  );
58
60
  const show = computed(() => !isAccessPending.value && canAccess.value);
61
+ const getRecordRepresentation = useGetRecordRepresentation(resource);
62
+ const confirmOptions = computed(() => {
63
+ const representation = getRecordRepresentation(record.value);
64
+ return {
65
+ name: translate(`resources.${resource}.forcedCaseName`, {
66
+ smart_count: 1,
67
+ _: humanize(
68
+ translate(`resources.${resource}.name`, {
69
+ smart_count: 1,
70
+ _: pluralize(resource, 1)
71
+ })
72
+ )
73
+ }),
74
+ recordRepresentation: typeof representation === "string" ? representation : "",
75
+ id: record.value?.id
76
+ };
77
+ });
59
78
  const label = computed(
60
79
  () => translate("ra.action.delete", { _: props.label ?? "Delete" })
61
80
  );
@@ -123,9 +142,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
123
142
  title: __props.confirmTitle,
124
143
  content: __props.confirmContent,
125
144
  "confirm-color": __props.confirmColor,
145
+ "translate-options": confirmOptions.value,
126
146
  onConfirm,
127
147
  onClose: onCancel
128
- }, null, 8, ["is-open", "loading", "title", "content", "confirm-color"])) : createCommentVNode("", true)
148
+ }, null, 8, ["is-open", "loading", "title", "content", "confirm-color", "translate-options"])) : createCommentVNode("", true)
129
149
  ], 64);
130
150
  };
131
151
  }
@@ -2,7 +2,7 @@ import { defineComponent, computed, openBlock, createElementBlock, normalizeClas
2
2
  import { useLoading, useRefresh } from "../../../data/use-refresh.js";
3
3
  import { useTranslate } from "../../../i18n/use-translate.js";
4
4
  import { cn } from "../../../lib/utils.js";
5
- import _sfc_main$2 from "../../ui/spinner2.vue.js";
5
+ import _sfc_main$2 from "../../ui/spinner.vue.js";
6
6
  import { RotateCwIcon } from "../buttons/icons.js";
7
7
  import _sfc_main$1 from "../common/icon-button-with-tooltip.vue.js";
8
8
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, normalizeClass, createCommentVNode } from "vue";
2
2
  import { cn } from "../../../lib/utils.js";
3
- import _sfc_main$1 from "../../ui/spinner2.vue.js";
3
+ import _sfc_main$1 from "../../ui/spinner.vue.js";
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  __name: "spinner",
6
6
  props: {
@@ -57,7 +57,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
57
57
  createVNode(_sfc_main$1, {
58
58
  variant: "ghost",
59
59
  size: "icon",
60
- "aria-label": unref(translate)("ra.navigation.previous", { _: "Previous" }),
60
+ "aria-label": unref(translate)("ra.calendar.previous", { _: "Previous" }),
61
61
  onClick: _cache[0] || (_cache[0] = ($event) => emit("navigate", "previous"))
62
62
  }, {
63
63
  default: withCtx(() => [
@@ -78,7 +78,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
78
78
  createVNode(_sfc_main$1, {
79
79
  variant: "ghost",
80
80
  size: "icon",
81
- "aria-label": unref(translate)("ra.navigation.next", { _: "Next" }),
81
+ "aria-label": unref(translate)("ra.calendar.next", { _: "Next" }),
82
82
  onClick: _cache[2] || (_cache[2] = ($event) => emit("navigate", "next"))
83
83
  }, {
84
84
  default: withCtx(() => [
@@ -98,8 +98,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
98
98
  );
99
99
  const rangeStartISO = computed(() => range.value.start.toISOString());
100
100
  const rangeEndISO = computed(() => range.value.end.toISOString());
101
- const LIST_DEFAULT_PER_PAGE = 10;
102
- const originalPerPage = list.perPage === props.perPage ? LIST_DEFAULT_PER_PAGE : list.perPage;
101
+ const originalPerPage = list.perPage === props.perPage ? list.defaultPerPage ?? 10 : list.perPage;
103
102
  let appliedKeys = [];
104
103
  const without = (filter, keys) => Object.fromEntries(
105
104
  Object.entries(filter).filter(([key]) => !keys.includes(key))
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, unref, openBlock, createBlock, normalizeClass, createCommentVNode } from "vue";
2
- import _sfc_main$1 from "../../ui/spinner2.vue.js";
2
+ import _sfc_main$1 from "../../ui/spinner.vue.js";
3
3
  import { useTimeout } from "../feedback/use-timeout.js";
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  __name: "count-spinner",
@@ -6,7 +6,7 @@ import { useForm } from "../../../form/use-form.js";
6
6
  import { useTranslate } from "../../../i18n/use-translate.js";
7
7
  import { cn } from "../../../lib/utils.js";
8
8
  import _sfc_main$2 from "../../ui/button.vue.js";
9
- import _sfc_main$3 from "../../ui/spinner2.vue.js";
9
+ import _sfc_main$3 from "../../ui/spinner.vue.js";
10
10
  import _sfc_main$1 from "../inputs/text-input.vue.js";
11
11
  import { useResetPassword } from "./use-password-recovery.js";
12
12
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -6,7 +6,7 @@ import { useForm } from "../../../form/use-form.js";
6
6
  import { useTranslate } from "../../../i18n/use-translate.js";
7
7
  import { cn } from "../../../lib/utils.js";
8
8
  import _sfc_main$2 from "../../ui/button.vue.js";
9
- import _sfc_main$3 from "../../ui/spinner2.vue.js";
9
+ import _sfc_main$3 from "../../ui/spinner.vue.js";
10
10
  import _sfc_main$1 from "../inputs/password-input.vue.js";
11
11
  import { useSupabaseUrlTokens, useSetPassword } from "./use-password-recovery.js";
12
12
  const _hoisted_1 = {
@@ -6,7 +6,7 @@ import { useTranslate } from "../../i18n/use-translate.js";
6
6
  import { useNotify } from "../../notification-hooks.js";
7
7
  import { useMapsConfig } from "../maps/use-map.js";
8
8
  import _sfc_main$1 from "../ui/button.vue.js";
9
- import _sfc_main$2 from "../ui/spinner2.vue.js";
9
+ import _sfc_main$2 from "../ui/spinner.vue.js";
10
10
  import { fetchOsmFeatures } from "./osm-features.js";
11
11
  import { subtractMask, unionAll } from "./osm-geometry-ops.js";
12
12
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -1,4 +1,32 @@
1
- import _sfc_main from "./spinner2.vue.js";
1
+ import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createElementVNode } from "vue";
2
+ import { cn } from "../../lib/utils.js";
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ __name: "spinner",
5
+ props: {
6
+ class: {}
7
+ },
8
+ setup(__props) {
9
+ const props = __props;
10
+ const classes = computed(() => cn("size-4 animate-spin", props.class));
11
+ return (_ctx, _cache) => {
12
+ return openBlock(), createElementBlock("svg", {
13
+ role: "status",
14
+ "aria-label": "Loading",
15
+ class: normalizeClass(classes.value),
16
+ "data-slot": "spinner",
17
+ viewBox: "0 0 24 24",
18
+ fill: "none",
19
+ stroke: "currentColor",
20
+ "stroke-width": "2",
21
+ "stroke-linecap": "round",
22
+ "stroke-linejoin": "round",
23
+ "aria-hidden": "false"
24
+ }, [..._cache[0] || (_cache[0] = [
25
+ createElementVNode("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }, null, -1)
26
+ ])], 2);
27
+ };
28
+ }
29
+ });
2
30
  export {
3
31
  _sfc_main as default
4
32
  };
@@ -1,32 +1,4 @@
1
- import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createElementVNode } from "vue";
2
- import { cn } from "../../lib/utils.js";
3
- const _sfc_main = /* @__PURE__ */ defineComponent({
4
- __name: "spinner",
5
- props: {
6
- class: {}
7
- },
8
- setup(__props) {
9
- const props = __props;
10
- const classes = computed(() => cn("size-4 animate-spin", props.class));
11
- return (_ctx, _cache) => {
12
- return openBlock(), createElementBlock("svg", {
13
- role: "status",
14
- "aria-label": "Loading",
15
- class: normalizeClass(classes.value),
16
- "data-slot": "spinner",
17
- viewBox: "0 0 24 24",
18
- fill: "none",
19
- stroke: "currentColor",
20
- "stroke-width": "2",
21
- "stroke-linecap": "round",
22
- "stroke-linejoin": "round",
23
- "aria-hidden": "false"
24
- }, [..._cache[0] || (_cache[0] = [
25
- createElementVNode("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }, null, -1)
26
- ])], 2);
27
- };
28
- }
29
- });
1
+ import _sfc_main from "./spinner.vue.js";
30
2
  export {
31
3
  _sfc_main as default
32
4
  };
@@ -1,4 +1,4 @@
1
- import { createInfiniteListController } from "@chelone/core";
1
+ import { createInfiniteListController, listControllerActions } from "@chelone/core";
2
2
  import { reactive, computed } from "vue";
3
3
  import { useCheloneContext } from "../context.js";
4
4
  import { useRequiredResource } from "../resource-context.js";
@@ -29,18 +29,7 @@ function useInfiniteListController(options = {}) {
29
29
  selectedIds: computed(() => state.value.selectedIds),
30
30
  hasNextPage: computed(() => state.value.hasNextPage),
31
31
  hasPreviousPage: computed(() => state.value.hasPreviousPage),
32
- setPage: controller.setPage,
33
- setPerPage: controller.setPerPage,
34
- setSort: controller.setSort,
35
- setFilters: controller.setFilters,
36
- setParams: controller.setParams,
37
- showFilter: controller.showFilter,
38
- hideFilter: controller.hideFilter,
39
- select: controller.select,
40
- toggleItem: controller.toggleItem,
41
- unselectAll: controller.unselectAll,
42
- selectAll: controller.selectAll,
43
- refetch: controller.refetch,
32
+ ...listControllerActions(controller),
44
33
  fetchNextPage: controller.fetchNextPage,
45
34
  fetchPreviousPage: controller.fetchPreviousPage
46
35
  });
@@ -1,4 +1,4 @@
1
- import { createListController, listPatchFromSearch, serializeListState } from "@chelone/core";
1
+ import { createListController, listPatchFromSearch, serializeListState, listControllerActions } from "@chelone/core";
2
2
  import { onScopeDispose, watch, reactive, computed } from "vue";
3
3
  import { useCheloneContext } from "../context.js";
4
4
  import { useRequiredResource } from "../resource-context.js";
@@ -53,18 +53,8 @@ function useListController(options = {}) {
53
53
  selectedIds: computed(() => state.value.selectedIds),
54
54
  hasNextPage: computed(() => state.value.hasNextPage),
55
55
  hasPreviousPage: computed(() => state.value.hasPreviousPage),
56
- setPage: controller.setPage,
57
- setPerPage: controller.setPerPage,
58
- setSort: controller.setSort,
59
- setFilters: controller.setFilters,
60
- setParams: controller.setParams,
61
- showFilter: controller.showFilter,
62
- hideFilter: controller.hideFilter,
63
- select: controller.select,
64
- toggleItem: controller.toggleItem,
65
- unselectAll: controller.unselectAll,
66
- selectAll: controller.selectAll,
67
- refetch: controller.refetch
56
+ ...listControllerActions(controller),
57
+ defaultPerPage: controller.defaultPerPage
68
58
  });
69
59
  }
70
60
  export {