@jskit-ai/http-web 0.1.95 → 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.
Files changed (49) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/locales/en.json +112 -0
  3. package/package.json +8 -7
  4. package/src/client/components/CrudAddEditScreen.vue +10 -4
  5. package/src/client/components/CrudDeleteAction.vue +10 -7
  6. package/src/client/components/CrudListBulkActionSurface.vue +19 -7
  7. package/src/client/components/CrudListDateFilterControl.vue +10 -5
  8. package/src/client/components/CrudListFilterControls.vue +25 -17
  9. package/src/client/components/CrudListFilterSurface.vue +14 -7
  10. package/src/client/components/CrudListRecordActionMenu.vue +17 -5
  11. package/src/client/components/CrudListScreen.vue +31 -18
  12. package/src/client/components/CrudViewScreen.vue +17 -7
  13. package/src/client/composables/crud/crudLookupFieldRuntime.js +4 -1
  14. package/src/client/composables/internal/crudListFilterLookupSupport.js +7 -4
  15. package/src/client/composables/internal/crudListParentTitleSupport.js +6 -3
  16. package/src/client/composables/records/useAddEdit.js +13 -7
  17. package/src/client/composables/records/useCrudList.js +6 -0
  18. package/src/client/composables/records/useCrudView.js +6 -0
  19. package/src/client/composables/records/useList.js +6 -3
  20. package/src/client/composables/records/useView.js +7 -4
  21. package/src/client/composables/runtime/operationValidationHelpers.js +16 -11
  22. package/src/client/composables/runtime/useAddEditCore.js +9 -6
  23. package/src/client/composables/runtime/useCommandCore.js +8 -5
  24. package/src/client/composables/runtime/useEndpointResource.js +7 -5
  25. package/src/client/composables/runtime/useListCore.js +5 -2
  26. package/src/client/composables/runtime/useUiFeedback.js +1 -1
  27. package/src/client/composables/runtime/useViewCore.js +5 -2
  28. package/src/client/composables/support/errorMessageHelpers.js +24 -8
  29. package/src/client/composables/support/listSearchSupport.js +4 -1
  30. package/src/client/composables/useAccess.js +4 -1
  31. package/src/client/composables/useCommand.js +5 -4
  32. package/src/client/composables/useCrudAddEditScreen.js +5 -2
  33. package/src/client/composables/useCrudDeleteAction.js +6 -3
  34. package/src/client/composables/useCrudListFilterLookups.js +6 -3
  35. package/src/client/composables/useCrudListFilters.js +5 -1
  36. package/src/client/composables/useCrudListParentTitle.js +5 -2
  37. package/src/client/composables/useCrudListScreen.js +8 -5
  38. package/src/client/composables/useCrudViewScreen.js +7 -4
  39. package/src/client/composables/usePagedCollection.js +5 -2
  40. package/src/client/composables/useScopeRuntime.js +7 -1
  41. package/src/client/i18n.js +8 -0
  42. package/src/client/support/crudListDateFilterSupport.js +18 -9
  43. package/test/crudListBulkActionSurface.test.js +1 -1
  44. package/test/crudListFilterSurface.test.js +2 -2
  45. package/test/crudScreenComponents.test.js +1 -1
  46. package/test/exportsContract.test.js +3 -1
  47. package/test/i18nCatalog.test.js +16 -0
  48. package/test/translation.test.js +164 -0
  49. package/test/useCrudListScreen.test.js +3 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,96 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 - 2026-10-29
4
+
5
+ - Translation ready: every user-visible text is a message key with its English in `locales/en.json`, so an app translates it by supplying translation files only. With no translations, texts and behaviour are unchanged. See the guide "Translating a JSKIT app".
6
+ - HTTP, network and validation errors render through the server code when its English matches JSKIT's, otherwise as sent.
7
+ - `useAddEdit`, `useCommand` and `useEndpointResource` message defaults are message keys rendered when shown; plain-text messages passed in still show as written.
8
+
9
+ ### New message keys (80)
10
+
11
+ All keys in `locales/en.json` (exported as `./locales/en.json`) are new in this version.
12
+
13
+ <details><summary>Key list</summary>
14
+
15
+ - `jskit.http.access.permissionsUnavailable`
16
+ - `jskit.http.access.routeParamsRequired`
17
+ - `jskit.http.actions.actions`
18
+ - `jskit.http.actions.apply`
19
+ - `jskit.http.actions.cancel`
20
+ - `jskit.http.actions.clear`
21
+ - `jskit.http.actions.clearAll`
22
+ - `jskit.http.actions.close`
23
+ - `jskit.http.actions.delete`
24
+ - `jskit.http.actions.deleting`
25
+ - `jskit.http.actions.edit`
26
+ - `jskit.http.actions.loadMore`
27
+ - `jskit.http.actions.loadingMore`
28
+ - `jskit.http.actions.more`
29
+ - `jskit.http.actions.open`
30
+ - `jskit.http.actions.refresh`
31
+ - `jskit.http.actions.refreshing`
32
+ - `jskit.http.actions.retry`
33
+ - `jskit.http.actions.retrying`
34
+ - `jskit.http.actions.running`
35
+ - `jskit.http.actions.save`
36
+ - `jskit.http.actions.saving`
37
+ - `jskit.http.crud.bulk.actions`
38
+ - `jskit.http.crud.bulk.selected`
39
+ - `jskit.http.crud.bulk.selection`
40
+ - `jskit.http.crud.delete.button`
41
+ - `jskit.http.crud.delete.description`
42
+ - `jskit.http.crud.delete.failed`
43
+ - `jskit.http.crud.delete.listRouteUnavailable`
44
+ - `jskit.http.crud.delete.title`
45
+ - `jskit.http.crud.filters.calendar`
46
+ - `jskit.http.crud.filters.chipDate`
47
+ - `jskit.http.crud.filters.chipFrom`
48
+ - `jskit.http.crud.filters.chipRange`
49
+ - `jskit.http.crud.filters.chipTo`
50
+ - `jskit.http.crud.filters.dateRange`
51
+ - `jskit.http.crud.filters.enterId`
52
+ - `jskit.http.crud.filters.enterIds`
53
+ - `jskit.http.crud.filters.option`
54
+ - `jskit.http.crud.filters.optionValue`
55
+ - `jskit.http.crud.filters.optionsLoadFailed`
56
+ - `jskit.http.crud.filters.rangeFrom`
57
+ - `jskit.http.crud.filters.rangeMax`
58
+ - `jskit.http.crud.filters.rangeMin`
59
+ - `jskit.http.crud.filters.rangeTo`
60
+ - `jskit.http.crud.filters.selectDate`
61
+ - `jskit.http.crud.filters.selectEndDate`
62
+ - `jskit.http.crud.filters.selectStartDate`
63
+ - `jskit.http.crud.filters.title`
64
+ - `jskit.http.crud.list.emptyBody`
65
+ - `jskit.http.crud.list.loadErrorBody`
66
+ - `jskit.http.crud.list.loadFailed`
67
+ - `jskit.http.crud.list.newRecord`
68
+ - `jskit.http.crud.list.selectRecord`
69
+ - `jskit.http.crud.list.selectVisibleRows`
70
+ - `jskit.http.crud.lookup.optionsLoadFailed`
71
+ - `jskit.http.crud.no`
72
+ - `jskit.http.crud.parent.loadFailed`
73
+ - `jskit.http.crud.parent.notFound`
74
+ - `jskit.http.crud.parent.recordWithId`
75
+ - `jskit.http.crud.record`
76
+ - `jskit.http.crud.recordNotFound`
77
+ - `jskit.http.crud.records`
78
+ - `jskit.http.crud.view.backTo`
79
+ - `jskit.http.crud.view.loadFailed`
80
+ - `jskit.http.crud.view.notFound`
81
+ - `jskit.http.crud.yes`
82
+ - `jskit.http.feedback.actionFailed`
83
+ - `jskit.http.feedback.completed`
84
+ - `jskit.http.feedback.fixInvalidValues`
85
+ - `jskit.http.feedback.requestFailed`
86
+ - `jskit.http.feedback.saveFailed`
87
+ - `jskit.http.feedback.saved`
88
+ - `jskit.http.feedback.validationFailed`
89
+ - `jskit.http.list.label`
90
+ - `jskit.http.list.loadFailed`
91
+ - `jskit.http.list.search`
92
+ - `jskit.http.resource.label`
93
+ - `jskit.http.resource.loadFailed`
94
+ - `jskit.http.resource.saveFailed`
95
+
96
+ </details>
@@ -0,0 +1,112 @@
1
+ {
2
+ "jskit": {
3
+ "http": {
4
+ "access": {
5
+ "permissionsUnavailable": "Permissions are unavailable in placement context.",
6
+ "routeParamsRequired": "Route parameters {params} are required for surface \"{surface}\"."
7
+ },
8
+ "actions": {
9
+ "actions": "Actions",
10
+ "apply": "Apply",
11
+ "cancel": "Cancel",
12
+ "clear": "Clear",
13
+ "clearAll": "Clear all",
14
+ "close": "Close",
15
+ "delete": "Delete",
16
+ "deleting": "Deleting…",
17
+ "edit": "Edit",
18
+ "loadMore": "Load more",
19
+ "loadingMore": "Loading more…",
20
+ "more": "More",
21
+ "open": "Open",
22
+ "refresh": "Refresh",
23
+ "refreshing": "Refreshing…",
24
+ "retry": "Retry",
25
+ "retrying": "Retrying…",
26
+ "running": "{label}…",
27
+ "save": "Save",
28
+ "saving": "Saving…"
29
+ },
30
+ "crud": {
31
+ "bulk": {
32
+ "actions": "Bulk actions",
33
+ "selected": "{count} selected",
34
+ "selection": "Selection"
35
+ },
36
+ "delete": {
37
+ "button": "Delete {resource}",
38
+ "description": "This permanently deletes this {resource}. This action cannot be undone.",
39
+ "failed": "Unable to delete record.",
40
+ "listRouteUnavailable": "Deleted the record, but the generated list route is unavailable.",
41
+ "title": "Delete {resource}?"
42
+ },
43
+ "filters": {
44
+ "calendar": "{label} calendar",
45
+ "chipDate": "{label}: {date}",
46
+ "chipFrom": "{label}: from {from}",
47
+ "chipRange": "{label}: {from} to {to}",
48
+ "chipTo": "{label}: to {to}",
49
+ "dateRange": "{label} date range",
50
+ "enterId": "Enter id",
51
+ "enterIds": "Enter ids",
52
+ "option": "Option",
53
+ "optionValue": "{label} {value}",
54
+ "optionsLoadFailed": "Unable to load filter options ({path}).",
55
+ "rangeFrom": "{label} from",
56
+ "rangeMax": "{label} max",
57
+ "rangeMin": "{label} min",
58
+ "rangeTo": "{label} to",
59
+ "selectDate": "Select date",
60
+ "selectEndDate": "Select end date",
61
+ "selectStartDate": "Select start date",
62
+ "title": "Filters"
63
+ },
64
+ "list": {
65
+ "emptyBody": "Create the first record to start using this workflow.",
66
+ "loadErrorBody": "Check the connection and try again.",
67
+ "loadFailed": "Unable to load records.",
68
+ "newRecord": "New record",
69
+ "selectRecord": "Select {title}",
70
+ "selectVisibleRows": "Select visible rows"
71
+ },
72
+ "lookup": {
73
+ "optionsLoadFailed": "Unable to load lookup options ({path})."
74
+ },
75
+ "no": "No",
76
+ "parent": {
77
+ "loadFailed": "Unable to load parent record.",
78
+ "notFound": "Parent record not found.",
79
+ "recordWithId": "{label} #{id}"
80
+ },
81
+ "record": "Record",
82
+ "recordNotFound": "Record not found.",
83
+ "records": "Records",
84
+ "view": {
85
+ "backTo": "Back to {resources}",
86
+ "loadFailed": "Unable to load record.",
87
+ "notFound": "This {resource} could not be found."
88
+ },
89
+ "yes": "Yes"
90
+ },
91
+ "feedback": {
92
+ "actionFailed": "Unable to complete action.",
93
+ "completed": "Completed.",
94
+ "fixInvalidValues": "Fix invalid values and try again.",
95
+ "requestFailed": "Request failed.",
96
+ "saveFailed": "Unable to save.",
97
+ "saved": "Saved.",
98
+ "validationFailed": "Validation failed."
99
+ },
100
+ "list": {
101
+ "label": "List",
102
+ "loadFailed": "Unable to load list.",
103
+ "search": "Search"
104
+ },
105
+ "resource": {
106
+ "label": "Resource",
107
+ "loadFailed": "Unable to load resource.",
108
+ "saveFailed": "Unable to save resource."
109
+ }
110
+ }
111
+ }
112
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/http-web",
3
- "version": "0.1.95",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test --test-concurrency=1"
@@ -41,17 +41,18 @@
41
41
  "./client/crudHttpClient": "./src/client/composables/crud/crudHttpClientSupport.js",
42
42
  "./client/lib/httpClient": "./src/client/lib/httpClient.js",
43
43
  "./client/lib/permissions": "./src/client/lib/permissions.js",
44
- "./client/support/contractGuards": "./src/client/support/contractGuards.js"
44
+ "./client/support/contractGuards": "./src/client/support/contractGuards.js",
45
+ "./locales/en.json": "./locales/en.json"
45
46
  },
46
47
  "dependencies": {
47
- "@jskit-ai/resource-crud-core": "0.1.189",
48
+ "@jskit-ai/resource-crud-core": "0.1.191",
48
49
  "@mdi/js": "^7.4.47"
49
50
  },
50
51
  "peerDependencies": {
51
- "@jskit-ai/http-runtime": "0.1.245",
52
- "@jskit-ai/kernel": "0.1.247",
53
- "@jskit-ai/realtime": "0.1.247",
54
- "@jskit-ai/shell-web": "0.1.254",
52
+ "@jskit-ai/http-runtime": "0.2.0",
53
+ "@jskit-ai/kernel": "0.2.0",
54
+ "@jskit-ai/realtime": "0.2.0",
55
+ "@jskit-ai/shell-web": "0.2.0",
55
56
  "@tanstack/vue-query": "^5.90.5",
56
57
  "vue": "^3.5.13",
57
58
  "vue-router": "^5.0.4",
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
2
  import { computed, unref } from "vue";
3
+ import { useJskitText } from "../i18n.js";
3
4
 
4
5
  const props = defineProps({
5
6
  screen: {
@@ -24,11 +25,14 @@ const props = defineProps({
24
25
  }
25
26
  });
26
27
 
28
+ const { t, text } = useJskitText();
27
29
  const formRuntime = computed(() => props.screen?.formRuntime || {});
28
30
  const addEdit = computed(() => props.screen?.addEdit || formRuntime.value?.addEdit || {});
29
31
  const formState = computed(() => props.screen?.formState || formRuntime.value?.form || {});
30
32
  const mode = computed(() => String(unref(props.screen?.mode) || "new").trim() || "new");
31
- const saveLabel = computed(() => String(unref(props.screen?.saveLabel) || "Save").trim() || "Save");
33
+ const saveLabel = computed(() =>
34
+ String(text(unref(props.screen?.saveLabel)) || "").trim() || t("jskit.http.actions.save")
35
+ );
32
36
  const cancelTo = computed(() => unref(props.screen?.cancelTo) || "");
33
37
 
34
38
  function resolveFieldErrors(fieldKey) {
@@ -63,14 +67,16 @@ function resolveCancelTo(target = cancelTo.value) {
63
67
  :cancel-to="resolveCancelTo()"
64
68
  :submit="addEdit.submit"
65
69
  >
66
- <v-btn v-if="cancelTo" color="primary" variant="outlined" :to="resolveCancelTo(cancelTo)">Cancel</v-btn>
70
+ <v-btn v-if="cancelTo" color="primary" variant="outlined" :to="resolveCancelTo(cancelTo)">
71
+ {{ t("jskit.http.actions.cancel") }}
72
+ </v-btn>
67
73
  <v-btn
68
74
  color="primary"
69
75
  variant="flat"
70
76
  :disabled="addEdit.isSubmitDisabled"
71
77
  @click="addEdit.submit"
72
78
  >
73
- {{ addEdit.isSaving ? "Saving…" : saveLabel }}
79
+ {{ addEdit.isSaving ? t("jskit.http.actions.saving") : saveLabel }}
74
80
  </v-btn>
75
81
  </slot>
76
82
  </div>
@@ -87,7 +93,7 @@ function resolveCancelTo(target = cancelTo.value) {
87
93
  :disabled="addEdit.isFetching"
88
94
  @click="addEdit.refresh"
89
95
  >
90
- {{ addEdit.isFetching ? "Retrying…" : "Retry" }}
96
+ {{ addEdit.isFetching ? t("jskit.http.actions.retrying") : t("jskit.http.actions.retry") }}
91
97
  </v-btn>
92
98
  </div>
93
99
  <template v-else-if="formRuntime.showFormSkeleton">
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed, useId } from "vue";
3
3
  import { mdiDeleteOutline } from "@mdi/js";
4
+ import { useJskitText } from "../i18n.js";
4
5
 
5
6
  const props = defineProps({
6
7
  action: {
@@ -9,12 +10,14 @@ const props = defineProps({
9
10
  },
10
11
  resourceSingularTitle: {
11
12
  type: String,
12
- default: "Record"
13
+ default: ""
13
14
  }
14
15
  });
15
16
 
17
+ const { t, text } = useJskitText();
18
+
16
19
  const resourceLabel = computed(() =>
17
- String(props.resourceSingularTitle || "Record").trim() || "Record"
20
+ String(text(props.resourceSingularTitle) || "").trim() || t("jskit.http.crud.record")
18
21
  );
19
22
  const componentId = useId();
20
23
  const titleId = `${componentId}-delete-title`;
@@ -40,7 +43,7 @@ function handleDialogModelUpdate(isOpen) {
40
43
  :disabled="!action.canDelete"
41
44
  @click="action.request"
42
45
  >
43
- Delete {{ resourceLabel }}
46
+ {{ t("jskit.http.crud.delete.button", { resource: resourceLabel }) }}
44
47
  </v-btn>
45
48
 
46
49
  <v-dialog
@@ -54,10 +57,10 @@ function handleDialogModelUpdate(isOpen) {
54
57
  @update:model-value="handleDialogModelUpdate"
55
58
  >
56
59
  <v-card>
57
- <v-card-title :id="titleId">Delete {{ resourceLabel }}?</v-card-title>
60
+ <v-card-title :id="titleId">{{ t("jskit.http.crud.delete.title", { resource: resourceLabel }) }}</v-card-title>
58
61
  <v-card-text>
59
62
  <p :id="descriptionId" class="mb-0">
60
- This permanently deletes this {{ resourceLabel.toLowerCase() }}. This action cannot be undone.
63
+ {{ t("jskit.http.crud.delete.description", { resource: resourceLabel.toLowerCase() }) }}
61
64
  </p>
62
65
  <v-alert
63
66
  v-if="action.error"
@@ -76,7 +79,7 @@ function handleDialogModelUpdate(isOpen) {
76
79
  :disabled="action.isDeleting"
77
80
  @click="closeDialog"
78
81
  >
79
- Cancel
82
+ {{ t("jskit.http.actions.cancel") }}
80
83
  </v-btn>
81
84
  <v-btn
82
85
  color="error"
@@ -84,7 +87,7 @@ function handleDialogModelUpdate(isOpen) {
84
87
  :disabled="!action.canDelete"
85
88
  @click="action.confirm"
86
89
  >
87
- {{ action.isDeleting ? "Deleting…" : "Delete" }}
90
+ {{ action.isDeleting ? t("jskit.http.actions.deleting") : t("jskit.http.actions.delete") }}
88
91
  </v-btn>
89
92
  </v-card-actions>
90
93
  </v-card>
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import { useDisplay } from "vuetify";
4
+ import { useJskitText } from "../i18n.js";
4
5
 
5
6
  const props = defineProps({
6
7
  runtime: {
@@ -9,10 +10,15 @@ const props = defineProps({
9
10
  },
10
11
  title: {
11
12
  type: String,
12
- default: "Selection"
13
+ default: undefined
13
14
  }
14
15
  });
15
16
 
17
+ const { t, text } = useJskitText();
18
+ const resolvedTitle = computed(() =>
19
+ props.title === undefined ? t("jskit.http.crud.bulk.selection") : text(props.title)
20
+ );
21
+
16
22
  const { smAndDown: isCompactLayout } = useDisplay();
17
23
 
18
24
  const actions = computed(() => Array.isArray(props.runtime?.actions) ? props.runtime.actions : []);
@@ -38,16 +44,22 @@ function isActionDisabled(action = {}) {
38
44
  function isActionExecuting(action = {}) {
39
45
  return Boolean(props.runtime?.isActionExecuting?.(action));
40
46
  }
47
+
48
+ // Action labels may be message keys.
49
+ function actionLabel(action = {}) {
50
+ const label = text(action.label);
51
+ return isActionExecuting(action) ? t("jskit.http.actions.running", { label }) : label;
52
+ }
41
53
  </script>
42
54
 
43
55
  <template>
44
56
  <section v-if="shouldRender" class="crud-list-bulk-action-surface">
45
57
  <div class="crud-list-bulk-action-surface__summary">
46
58
  <div class="crud-list-bulk-action-surface__copy">
47
- <span class="text-overline text-medium-emphasis">{{ title }}</span>
48
- <strong>{{ selectedCount }} selected</strong>
59
+ <span class="text-overline text-medium-emphasis">{{ resolvedTitle }}</span>
60
+ <strong>{{ t("jskit.http.crud.bulk.selected", { count: selectedCount }) }}</strong>
49
61
  </div>
50
- <v-btn size="small" variant="text" @click="clearSelection">Clear</v-btn>
62
+ <v-btn size="small" variant="text" @click="clearSelection">{{ t("jskit.http.actions.clear") }}</v-btn>
51
63
  </div>
52
64
 
53
65
  <div v-if="!isCompactLayout" class="crud-list-bulk-action-surface__actions">
@@ -60,19 +72,19 @@ function isActionExecuting(action = {}) {
60
72
  :disabled="isActionDisabled(action)"
61
73
  @click="execute(action)"
62
74
  >
63
- {{ isActionExecuting(action) ? `${action.label}…` : action.label }}
75
+ {{ actionLabel(action) }}
64
76
  </v-btn>
65
77
  </div>
66
78
 
67
79
  <v-menu v-else location="bottom end">
68
80
  <template #activator="{ props: menuProps }">
69
- <v-btn v-bind="menuProps" color="primary" variant="tonal">Bulk actions</v-btn>
81
+ <v-btn v-bind="menuProps" color="primary" variant="tonal">{{ t("jskit.http.crud.bulk.actions") }}</v-btn>
70
82
  </template>
71
83
  <v-list density="compact" min-width="180">
72
84
  <v-list-item
73
85
  v-for="action in actions"
74
86
  :key="action.key"
75
- :title="isActionExecuting(action) ? `${action.label}…` : action.label"
87
+ :title="actionLabel(action)"
76
88
  :prepend-icon="action.icon || undefined"
77
89
  :disabled="isActionDisabled(action)"
78
90
  @click="execute(action)"
@@ -6,6 +6,7 @@ import {
6
6
  formatDateOnlyValue,
7
7
  formatDateOnlyDisplay
8
8
  } from "../support/crudListDateFilterSupport.js";
9
+ import { useJskitText } from "../i18n.js";
9
10
 
10
11
  defineOptions({
11
12
  inheritAttrs: false
@@ -26,7 +27,7 @@ const props = defineProps({
26
27
  },
27
28
  placeholder: {
28
29
  type: String,
29
- default: "Select date"
30
+ default: undefined
30
31
  },
31
32
  disabled: {
32
33
  type: Boolean,
@@ -39,6 +40,10 @@ const props = defineProps({
39
40
  });
40
41
 
41
42
  const emit = defineEmits(["update:modelValue"]);
43
+ const { t } = useJskitText();
44
+ const resolvedPlaceholder = computed(() =>
45
+ props.placeholder === undefined ? t("jskit.http.crud.filters.selectDate") : props.placeholder
46
+ );
42
47
  const attrs = useAttrs();
43
48
  const { current: currentLocale } = useLocale();
44
49
  const generatedId = useId();
@@ -51,7 +56,7 @@ const pickerValue = computed(() => parseDateOnlyValue(props.modelValue));
51
56
  const displayValue = computed(() => formatDateOnlyDisplay(props.modelValue, {
52
57
  locale: currentLocale?.value
53
58
  }));
54
- const pickerTitle = computed(() => `${props.label} calendar`);
59
+ const pickerTitle = computed(() => t("jskit.http.crud.filters.calendar", { label: props.label }));
55
60
 
56
61
  function restoreFocus() {
57
62
  void nextTick(() => {
@@ -113,7 +118,7 @@ function handleActivatorKeydown(event) {
113
118
  ref="textFieldRef"
114
119
  :model-value="displayValue"
115
120
  :label="label"
116
- :placeholder="placeholder"
121
+ :placeholder="resolvedPlaceholder"
117
122
  :aria-label="label"
118
123
  :aria-controls="pickerId"
119
124
  :aria-expanded="String(menuOpen)"
@@ -161,10 +166,10 @@ function handleActivatorKeydown(event) {
161
166
  :disabled="disabled || readonly || !modelValue"
162
167
  @click="clearDate"
163
168
  >
164
- Clear
169
+ {{ t("jskit.http.actions.clear") }}
165
170
  </v-btn>
166
171
  <v-spacer />
167
- <v-btn color="primary" variant="text" @click="closeMenu">Close</v-btn>
172
+ <v-btn color="primary" variant="text" @click="closeMenu">{{ t("jskit.http.actions.close") }}</v-btn>
168
173
  </v-card-actions>
169
174
  </v-card>
170
175
  </v-menu>
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import CrudListDateFilterControl from "./CrudListDateFilterControl.vue";
4
+ import { useJskitText } from "../i18n.js";
4
5
 
5
6
  const props = defineProps({
6
7
  filters: {
@@ -17,14 +18,21 @@ const props = defineProps({
17
18
  }
18
19
  });
19
20
 
21
+ const { t, text } = useJskitText();
20
22
  const runtimeValues = computed(() => props.runtime?.values || {});
21
23
 
22
24
  function optionItems(filter = {}) {
23
25
  return Array.isArray(filter.options) ? filter.options : [];
24
26
  }
25
27
 
26
- function placeholder(filter = {}, fallback = "") {
27
- return String(filter?.ui?.placeholder || fallback || "").trim();
28
+ // Filter labels and placeholders may be message keys.
29
+ function filterLabel(filter = {}, key = "", params = {}) {
30
+ const label = text(filter.label);
31
+ return key ? t(key, { ...params, label }) : label;
32
+ }
33
+
34
+ function placeholder(filter = {}, fallbackKey = "") {
35
+ return String(text(filter?.ui?.placeholder) || (fallbackKey ? t(fallbackKey) : "")).trim();
28
36
  }
29
37
  </script>
30
38
 
@@ -37,7 +45,7 @@ function placeholder(filter = {}, fallback = "") {
37
45
  <v-switch
38
46
  v-if="filter.type === 'flag'"
39
47
  v-model="runtimeValues[filter.key]"
40
- :label="filter.label"
48
+ :label="filterLabel(filter)"
41
49
  color="primary"
42
50
  density="comfortable"
43
51
  hide-details
@@ -47,7 +55,7 @@ function placeholder(filter = {}, fallback = "") {
47
55
  v-else-if="filter.type === 'enum' || filter.type === 'enumMany' || filter.type === 'presence'"
48
56
  v-model="runtimeValues[filter.key]"
49
57
  :items="optionItems(filter)"
50
- :label="filter.label"
58
+ :label="filterLabel(filter)"
51
59
  :placeholder="placeholder(filter)"
52
60
  :multiple="filter.type === 'enumMany'"
53
61
  :chips="filter.type === 'enumMany'"
@@ -63,8 +71,8 @@ function placeholder(filter = {}, fallback = "") {
63
71
  <v-combobox
64
72
  v-else-if="filter.type === 'recordIdMany'"
65
73
  v-model="runtimeValues[filter.key]"
66
- :label="filter.label"
67
- :placeholder="placeholder(filter, 'Enter ids')"
74
+ :label="filterLabel(filter)"
75
+ :placeholder="placeholder(filter, 'jskit.http.crud.filters.enterIds')"
68
76
  multiple
69
77
  chips
70
78
  closable-chips
@@ -77,8 +85,8 @@ function placeholder(filter = {}, fallback = "") {
77
85
  <v-text-field
78
86
  v-else-if="filter.type === 'recordId'"
79
87
  v-model="runtimeValues[filter.key]"
80
- :label="filter.label"
81
- :placeholder="placeholder(filter, 'Enter id')"
88
+ :label="filterLabel(filter)"
89
+ :placeholder="placeholder(filter, 'jskit.http.crud.filters.enterId')"
82
90
  clearable
83
91
  variant="outlined"
84
92
  density="comfortable"
@@ -89,27 +97,27 @@ function placeholder(filter = {}, fallback = "") {
89
97
  v-else-if="filter.type === 'dateRange'"
90
98
  class="crud-list-filter-surface__range crud-list-filter-surface__range--date"
91
99
  role="group"
92
- :aria-label="`${filter.label} date range`"
100
+ :aria-label="filterLabel(filter, 'jskit.http.crud.filters.dateRange')"
93
101
  :data-filter-key="filter.key"
94
102
  data-filter-type="date-range"
95
103
  >
96
104
  <CrudListDateFilterControl
97
105
  v-model="runtimeValues[filter.key].from"
98
- :label="`${filter.label} from`"
106
+ :label="filterLabel(filter, 'jskit.http.crud.filters.rangeFrom')"
99
107
  :control-id="`${filter.key}-from`"
100
- :placeholder="placeholder(filter, 'Select start date')"
108
+ :placeholder="placeholder(filter, 'jskit.http.crud.filters.selectStartDate')"
101
109
  />
102
110
  <CrudListDateFilterControl
103
111
  v-model="runtimeValues[filter.key].to"
104
- :label="`${filter.label} to`"
112
+ :label="filterLabel(filter, 'jskit.http.crud.filters.rangeTo')"
105
113
  :control-id="`${filter.key}-to`"
106
- :placeholder="placeholder(filter, 'Select end date')"
114
+ :placeholder="placeholder(filter, 'jskit.http.crud.filters.selectEndDate')"
107
115
  />
108
116
  </div>
109
117
  <div v-else-if="filter.type === 'numberRange'" class="crud-list-filter-surface__range">
110
118
  <v-text-field
111
119
  v-model="runtimeValues[filter.key].min"
112
- :label="`${filter.label} min`"
120
+ :label="filterLabel(filter, 'jskit.http.crud.filters.rangeMin')"
113
121
  type="number"
114
122
  variant="outlined"
115
123
  density="comfortable"
@@ -117,7 +125,7 @@ function placeholder(filter = {}, fallback = "") {
117
125
  />
118
126
  <v-text-field
119
127
  v-model="runtimeValues[filter.key].max"
120
- :label="`${filter.label} max`"
128
+ :label="filterLabel(filter, 'jskit.http.crud.filters.rangeMax')"
121
129
  type="number"
122
130
  variant="outlined"
123
131
  density="comfortable"
@@ -127,9 +135,9 @@ function placeholder(filter = {}, fallback = "") {
127
135
  <CrudListDateFilterControl
128
136
  v-else-if="filter.type === 'date'"
129
137
  v-model="runtimeValues[filter.key]"
130
- :label="filter.label"
138
+ :label="filterLabel(filter)"
131
139
  :control-id="filter.key"
132
- :placeholder="placeholder(filter, 'Select date')"
140
+ :placeholder="placeholder(filter, 'jskit.http.crud.filters.selectDate')"
133
141
  class="crud-list-filter-surface__control"
134
142
  />
135
143
  </template>