@antelopejs/dms-lang 0.5.1 → 0.5.2

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/README.md CHANGED
@@ -1,13 +1,14 @@
1
+ <a href="https://github.com/AntelopeJS/dms"><img data-illustration src="./.github/readme/strip.svg" width="100%" alt="DMS TRANSLATIONS: part of AntelopeJS DMS, the open-source back office. A glowing button reads Star AntelopeJS DMS."></a>
2
+
1
3
  <div align="center">
2
4
 
3
5
  # `@antelopejs/dms-lang`
4
6
 
5
- <a href="https://www.npmjs.com/package/@antelopejs/dms-lang"><img alt="npm" src="https://img.shields.io/npm/v/@antelopejs/dms-lang?style=for-the-badge&labelColor=000000&color=000000" data-illustration></a>
6
- <a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/dms-lang?style=for-the-badge&labelColor=000000&color=000000" data-illustration></a>
7
- <a href="https://discord.gg/g4pFt6eXqu"><img alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000" data-illustration></a>
8
- <a href="https://dms.antelopejs.com/docs/modules/lang"><img alt="Documentation" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" data-illustration></a>
7
+ <a href="https://www.npmjs.com/package/@antelopejs/dms-lang"><img alt="npm" src="https://img.shields.io/npm/v/@antelopejs/dms-lang?style=for-the-badge&labelColor=000000&color=000000" data-illustration></a> <a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/dms-lang?style=for-the-badge&labelColor=000000&color=000000" data-illustration></a> <a href="https://discord.gg/g4pFt6eXqu"><img alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000" data-illustration></a> <a href="https://dms.antelopejs.com/docs/modules/lang"><img alt="Documentation" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" data-illustration></a> <a href="https://github.com/AntelopeJS/dms"><img data-illustration alt="Star AntelopeJS DMS" src="https://img.shields.io/github/stars/AntelopeJS/dms?label=Star%20AntelopeJS%20DMS&style=for-the-badge&labelColor=000000&color=000000&logo=github"></a>
8
+
9
+ **See how complete each language is, and translate the missing keys in a matrix or one key at a time.**
9
10
 
10
- Language and translation management for the [AntelopeJS DMS](https://github.com/AntelopeJS/dms).
11
+ [Try it in the live demo](https://dms-demo.antelopejs.com/modules/lang) · [Documentation](https://dms.antelopejs.com/docs/modules/lang) · [All modules](https://github.com/AntelopeJS/dms#modules)
11
12
 
12
13
  </div>
13
14
 
@@ -93,6 +94,28 @@ pnpm test
93
94
 
94
95
  </details>
95
96
 
97
+ ## Part of AntelopeJS DMS
98
+
99
+ This module installs into [AntelopeJS DMS](https://github.com/AntelopeJS/dms), the open-source back office. Every module adds its pages to the same dashboard, behind the same sign-in and roles.
100
+
101
+ <!-- antelopejs-dms-modules:start -->
102
+
103
+ | Module | What it adds |
104
+ | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
105
+ | [`dms-builder`](https://github.com/AntelopeJS/dms-builder) | Edit pages, tables and data sources by clicking, as TypeScript that compiles |
106
+ | [`dms-ai`](https://github.com/AntelopeJS/dms-ai) | An assistant chat in the dashboard, on your own Claude Code or Codex |
107
+ | [`dms-database`](https://github.com/AntelopeJS/dms-database) | Schemas, relation diagrams, a data browser and a query console |
108
+ | [`dms-api`](https://github.com/AntelopeJS/dms-api) | API health, request logs, per-route statistics and a request tester |
109
+ | [`dms-automation`](https://github.com/AntelopeJS/dms-automation) | Node-graph automations on schedules, webhooks and DMS events, with a trace for every run |
110
+ | [`dms-mailing`](https://github.com/AntelopeJS/dms-mailing) | E-mail templates in a block editor, versions, a send log and delivery metrics |
111
+ | [`dms-lang`](https://github.com/AntelopeJS/dms-lang) | Translation coverage, a translation matrix and a translation queue |
112
+ | [`dms-media`](https://github.com/AntelopeJS/dms-media) | A media library with folders, per-folder permissions, image sizes and light editing |
113
+ | [`dms-saas`](https://github.com/AntelopeJS/dms-saas) | Self-service sign-up, plans that gate features, and Stripe billing |
114
+ | [`dms-marketing`](https://github.com/AntelopeJS/dms-marketing) | Traffic, conversion funnels with A/B splits and click heatmaps, without cookies |
115
+ | [`dms-frontend`](https://github.com/AntelopeJS/dms-frontend) | The `ajs dms` CLI, the Vue renderer and the SDK every frontend module builds on |
116
+
117
+ <!-- antelopejs-dms-modules:end -->
118
+
96
119
  ## License
97
120
 
98
121
  [Apache-2.0](./LICENSE)
@@ -8,6 +8,7 @@ import {
8
8
  import type { CellHold } from '../composables/useCellSaves'
9
9
  import {
10
10
  clearsBaseText,
11
+ useBaseClearQuestion,
11
12
  useEditStarts,
12
13
  useKeySaves,
13
14
  useSaveStates,
@@ -96,6 +97,11 @@ const knownInherited = ref<KnownInherited | null>(null)
96
97
  const fieldStates = ref<Record<string, SaveState>>({})
97
98
  const fieldErrors = ref<Record<string, string>>({})
98
99
  const blocked = ref<Record<string, boolean>>({})
100
+ const {
101
+ question: baseClear,
102
+ ask: askBaseClear,
103
+ left: baseClearLeft,
104
+ } = useBaseClearQuestion()
99
105
  const states = useSaveStates(fieldStates)
100
106
  const body = useTemplateRef<HTMLElement>('body')
101
107
  const fieldIds = useId()
@@ -337,7 +343,7 @@ function isClearingBase(codes: string[]): boolean {
337
343
 
338
344
  async function confirmBaseClear(codes: string[]) {
339
345
  if (!isClearingBase(codes)) return
340
- if (!(await saves.confirmClearBase(key.value))) discardDraft(base.value)
346
+ if (!(await askBaseClear(key.value))) discardDraft(base.value)
341
347
  }
342
348
 
343
349
  async function persist(codes: string[]): Promise<boolean> {
@@ -652,5 +658,12 @@ onMounted(() => show(key.value))
652
658
  </div>
653
659
  </div>
654
660
  </DmsContainerFooter>
661
+ <DmsConfirmModal
662
+ v-for="question in baseClear ? [baseClear] : []"
663
+ :key="question.id"
664
+ v-bind="saves.clearBaseDialog(question.key)"
665
+ @close="question.answer"
666
+ @after:leave="baseClearLeft(question.id)"
667
+ />
655
668
  </div>
656
669
  </template>
@@ -0,0 +1,61 @@
1
+ import { tryOnScopeDispose, useEventListener } from '@vueuse/core'
2
+
3
+ /** How long a touch or pen tap may take to make its click. */
4
+ const TAP_CLICK_TIMEOUT_MS = 1000
5
+
6
+ /**
7
+ * Defers work to the click of the primary-button press in progress, so a save
8
+ * started by the blur that press causes changes nothing on the page until
9
+ * that click has landed. A touch tap blurs after its `pointerup`, so the
10
+ * press lasts until the click, a `pointercancel`, the window's blur, a press
11
+ * of another button or, for a tap that makes no click,
12
+ * {@link TAP_CLICK_TIMEOUT_MS}. Without such a
13
+ * press, the work runs at once; work still waiting when the scope ends runs
14
+ * then.
15
+ */
16
+ export function useAfterPress(): (run: () => void) => void {
17
+ let isPressed = false
18
+ let waiting: (() => void)[] = []
19
+ let tapTimer: ReturnType<typeof setTimeout> | undefined
20
+
21
+ function flush() {
22
+ const runs = waiting
23
+ waiting = []
24
+ for (const run of runs) run()
25
+ }
26
+
27
+ function release() {
28
+ clearTimeout(tapTimer)
29
+ isPressed = false
30
+ if (waiting.length) setTimeout(flush)
31
+ }
32
+
33
+ function onPointerUp(event: PointerEvent) {
34
+ if (!isPressed) return
35
+ if (event.pointerType === 'mouse') release()
36
+ else tapTimer = setTimeout(release, TAP_CLICK_TIMEOUT_MS)
37
+ }
38
+
39
+ const capture = { capture: true, passive: true }
40
+ useEventListener(
41
+ 'pointerdown',
42
+ (event) => {
43
+ clearTimeout(tapTimer)
44
+ if (event.isPrimary && event.button === 0) isPressed = true
45
+ else release()
46
+ },
47
+ capture,
48
+ )
49
+ useEventListener('pointerup', onPointerUp, capture)
50
+ useEventListener(['click', 'pointercancel'], release, capture)
51
+ useEventListener('blur', release)
52
+ tryOnScopeDispose(() => {
53
+ clearTimeout(tapTimer)
54
+ flush()
55
+ })
56
+
57
+ return (run) => {
58
+ if (isPressed) waiting.push(run)
59
+ else run()
60
+ }
61
+ }
@@ -214,6 +214,12 @@ export function useKeySaves() {
214
214
  errorMessage,
215
215
  translate: (key, params) => t(key, params),
216
216
  }
217
+ const clearBaseDialog = (key: string) => ({
218
+ title: t('dms_lang.matrix.clear_base_title', { key }),
219
+ description: t('dms_lang.matrix.clear_base_description'),
220
+ color: 'warning' as const,
221
+ confirmLabel: t('dms_lang.matrix.clear_base_confirm'),
222
+ })
217
223
 
218
224
  return {
219
225
  /** Queues texts of a key behind the earlier writes of the same texts. */
@@ -224,17 +230,42 @@ export function useKeySaves() {
224
230
  /** Takes a key deleted elsewhere off the translations every page shows. */
225
231
  dropRow: (target: KeyTarget) =>
226
232
  translations.replaceRow(target.workspace, target.key, undefined),
233
+ /** The dialog that asks before a base text is emptied, for a panel that renders it itself. */
234
+ clearBaseDialog,
227
235
  /** Asks before a base text is emptied: the key would go missing everywhere. */
228
- confirmClearBase: (key: string) =>
229
- confirm({
230
- title: t('dms_lang.matrix.clear_base_title', { key }),
231
- description: t('dms_lang.matrix.clear_base_description'),
232
- color: 'warning',
233
- confirmLabel: t('dms_lang.matrix.clear_base_confirm'),
234
- }),
236
+ confirmClearBase: (key: string) => confirm(clearBaseDialog(key)),
235
237
  }
236
238
  }
237
239
 
240
+ /** A confirmation to clear a base text, shown by a dialog its caller renders. */
241
+ interface BaseClearQuestion {
242
+ /** Tells one question from the next: each gets a dialog of its own. */
243
+ id: number
244
+ key: string
245
+ answer: (confirmed: boolean) => void
246
+ }
247
+
248
+ /**
249
+ * Asks before a base text is emptied, in a dialog the caller renders (see
250
+ * `clearBaseDialog`) so it opens in the caller's layer: the key panel's
251
+ * drawer, which the DMS's own dialogs open under. `question` holds the last
252
+ * one asked until its dialog has left the screen (`left`); a question asked
253
+ * while the previous dialog leaves replaces it and stays.
254
+ */
255
+ export function useBaseClearQuestion() {
256
+ const question = shallowRef<BaseClearQuestion | null>(null)
257
+ let asked = 0
258
+ const ask = (key: string) =>
259
+ new Promise<boolean>((answer) => {
260
+ asked += 1
261
+ question.value = { id: asked, key, answer }
262
+ })
263
+ const left = (id: number) => {
264
+ if (question.value?.id === id) question.value = null
265
+ }
266
+ return { question, ask, left }
267
+ }
268
+
238
269
  /** The save state of each text of a set, a save flashing "Saved" for a moment. */
239
270
  export function useSaveStates(states: Ref<Record<string, SaveState>>) {
240
271
  function stateOf(id: string): SaveState {
@@ -45,17 +45,14 @@ export function parseFilter(value: string | undefined): TranslationFilter {
45
45
 
46
46
  /**
47
47
  * The languages the counts and the filters look at: the one being translated,
48
- * else the target languages shown as columns, else every target language.
48
+ * else every target language, whatever columns are shown.
49
49
  */
50
50
  export function targetLocales(
51
51
  flat: FlatTranslations,
52
52
  missingIn: string,
53
- shown: string[],
54
53
  ): string[] {
55
54
  if (missingIn && flat.locales.includes(missingIn)) return [missingIn]
56
- const targets = flat.locales.filter((code) => code !== flat.defaultLocale)
57
- const visible = targets.filter((code) => shown.includes(code))
58
- return visible.length ? visible : targets
55
+ return flat.locales.filter((code) => code !== flat.defaultLocale)
59
56
  }
60
57
 
61
58
  function rowStatus(
@@ -104,10 +101,9 @@ const NO_STATUS: RowStatus = { missing: [], hasIssue: false }
104
101
  function useRowStatuses(
105
102
  flat: Ref<FlatTranslations>,
106
103
  state: Ref<MatrixFilterState>,
107
- shown: Ref<string[]>,
108
104
  ) {
109
105
  const targets = computed(() =>
110
- targetLocales(flat.value, state.value.missingIn, shown.value),
106
+ targetLocales(flat.value, state.value.missingIn),
111
107
  )
112
108
  const statuses = computed(() => {
113
109
  const base = flat.value.defaultLocale
@@ -165,13 +161,11 @@ function useScopedRows(
165
161
  export function useMatrixFilters(
166
162
  flat: Ref<FlatTranslations>,
167
163
  state: Ref<MatrixFilterState>,
168
- shown: Ref<string[]>,
169
164
  pinned: Ref<Set<string>>,
170
165
  ) {
171
166
  const { targets, statusOf, isRowMissing, predicates } = useRowStatuses(
172
167
  flat,
173
168
  state,
174
- shown,
175
169
  )
176
170
  const { namespaces, scoped } = useScopedRows(flat, state)
177
171
  const matches = (row: FlatTranslationRow) =>
@@ -129,7 +129,7 @@ const tableMinWidth = computed(() => {
129
129
  })
130
130
 
131
131
  const { rows, groups, counts, targets, namespaces, isRowDone } =
132
- useMatrixFilters(flat, filters, columnCodes, pinned)
132
+ useMatrixFilters(flat, filters, pinned)
133
133
  const doneCount = computed(() => rows.value.filter(isRowFinished).length)
134
134
  const rowCount = computed(() => rows.value.length)
135
135
  const view = useMatrixRows(groups, rowCount)
@@ -4,6 +4,7 @@ import type { WorkspaceType } from '../types/lang'
4
4
  import type { SaveState } from '../utils/keySaves'
5
5
  import LocaleTile from '../build/components/LocaleTile.vue'
6
6
  import { useSaveStates } from '../build/composables/useKeySaves'
7
+ import { useAfterPress } from '../build/composables/useAfterPress'
7
8
 
8
9
  /** A setting of the page, each saved on its own. */
9
10
  type DetailField = 'description' | 'type' | 'base'
@@ -16,6 +17,7 @@ const { addLanguage, makeBase } = useLanguageActions()
16
17
  const { updateDetails } = useWorkspaceActions()
17
18
  const { typeItems, typeOf, descriptionMax } = useWorkspaceTypes()
18
19
  const { route } = useWorkspaceRoute()
20
+ const afterPress = useAfterPress()
19
21
 
20
22
  const workspaceId = computed(() => route.query.workspace ?? '')
21
23
  const canEditDetails = computed(
@@ -62,7 +64,9 @@ const isTypingDescription = ref(false)
62
64
  watch(
63
65
  () => current.value?.description,
64
66
  (text) => {
65
- if (isTypingDescription.value || stateOf('description') === 'error') return
67
+ const state = stateOf('description')
68
+ if (isTypingDescription.value || state === 'error' || state === 'saving')
69
+ return
66
70
  description.value = text ?? ''
67
71
  },
68
72
  { immediate: true },
@@ -72,8 +76,15 @@ function saveDescription() {
72
76
  isTypingDescription.value = false
73
77
  const text = description.value.trim()
74
78
  if (text === (current.value?.description ?? '')) return
75
- void track('description', () =>
76
- updateDetails(workspaceId.value, { description: text || null }),
79
+ const id = workspaceId.value
80
+ afterPress(
81
+ () =>
82
+ void track('description', async () => {
83
+ const saved = await updateDetails(id, { description: text || null })
84
+ if (saved && !isTypingDescription.value)
85
+ description.value = current.value?.description ?? ''
86
+ return saved
87
+ }),
77
88
  )
78
89
  }
79
90
 
@@ -130,7 +141,7 @@ usePageHeaderActions(() =>
130
141
  :label="$t('dms_lang.workspace.source_label')"
131
142
  :description="$t(`dms_lang.workspace.source_help_${kind}`)"
132
143
  >
133
- <code class="text-muted font-mono text-xs break-all">
144
+ <code class="text-muted break-all font-mono text-xs">
134
145
  {{ $t(`dms_lang.workspace_kinds.${kind}.folder`) }}
135
146
  </code>
136
147
  </DmsFieldRow>
@@ -157,7 +168,7 @@ usePageHeaderActions(() =>
157
168
  <p v-else class="text-highlighted text-sm">
158
169
  {{ current?.description || '—' }}
159
170
  </p>
160
- <template #details>
171
+ <template #label-extra>
161
172
  <DmsSaveStatus
162
173
  :state="stateOf('description')"
163
174
  @retry="retries.description?.()"
@@ -174,7 +185,7 @@ usePageHeaderActions(() =>
174
185
  :items="typeItems"
175
186
  :disabled="!canEditDetails"
176
187
  />
177
- <template #details>
188
+ <template #label-extra>
178
189
  <DmsSaveStatus :state="stateOf('type')" @retry="retries.type?.()" />
179
190
  </template>
180
191
  </DmsFieldRow>
@@ -206,7 +217,7 @@ usePageHeaderActions(() =>
206
217
  {{ baseLocale }}
207
218
  </span>
208
219
  </span>
209
- <template #details>
220
+ <template #label-extra>
210
221
  <DmsSaveStatus :state="stateOf('base')" />
211
222
  </template>
212
223
  </DmsFieldRow>
@@ -381,7 +381,7 @@ watch(
381
381
  </div>
382
382
 
383
383
  <template #footer>
384
- <div class="flex items-center gap-2.5">
384
+ <div class="flex min-w-0 flex-1 items-center gap-2.5">
385
385
  <template v-if="workspace.kind === 'added'">
386
386
  <DmsStatusPill
387
387
  tone="success"
@@ -544,7 +544,7 @@
544
544
  "label": "Workspace name",
545
545
  "placeholder": "partner-portal",
546
546
  "help": "Lowercase letters, digits, dashes and underscores.",
547
- "invalid": "Use lowercase letters, digits, dashes and underscores; default, modules and all are reserved.",
547
+ "invalid": "Use lowercase letters, digits, dashes and underscores; default and modules are reserved.",
548
548
  "taken": "A workspace named {name} already exists.",
549
549
  "unchanged": "This is the current name.",
550
550
  "available": "{name} is available."
@@ -544,7 +544,7 @@
544
544
  "label": "Nom de l'espace",
545
545
  "placeholder": "portail-partenaire",
546
546
  "help": "Lettres minuscules, chiffres, tirets et tirets bas.",
547
- "invalid": "Utilisez des lettres minuscules, des chiffres, des tirets et des tirets bas ; default, modules et all sont réservés.",
547
+ "invalid": "Utilisez des lettres minuscules, des chiffres, des tirets et des tirets bas ; default et modules sont réservés.",
548
548
  "taken": "Un espace nommé {name} existe déjà.",
549
549
  "unchanged": "C'est le nom actuel.",
550
550
  "available": "{name} est disponible."
@@ -18,7 +18,7 @@
18
18
  "lint:fix": "eslint . --fix"
19
19
  },
20
20
  "devDependencies": {
21
- "@antelopejs/core": "1.20.0",
21
+ "@antelopejs/core": "1.21.0",
22
22
  "@antelopejs/dms-frontend": ">=0.10.0 <0.11.0",
23
23
  "@eslint/js": "^9",
24
24
  "@typescript-eslint/eslint-plugin": "^8",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-lang",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Language and translation management for the AntelopeJS DMS: coverage overview, translation matrix, translation queue and public translation workspaces.",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -75,13 +75,13 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@antelopejs/api": "^1.7.0",
78
- "@antelopejs/core": "1.20.0",
79
- "@antelopejs/dms": ">=0.13.1 <1.0.0",
78
+ "@antelopejs/core": "1.21.0",
79
+ "@antelopejs/dms": ">=0.17.0 <1.0.0",
80
80
  "@antelopejs/dms-frontend": ">=0.10.0 <1.0.0",
81
81
  "@antelopejs/interface-data-api": ">=0.6.0 <1.0.0",
82
82
  "@antelopejs/interface-database": ">=0.3.0 <1.0.0",
83
83
  "@antelopejs/interface-database-decorators": ">=0.2.0 <1.0.0",
84
- "@antelopejs/tooling-configs": "^0.2.18",
84
+ "@antelopejs/tooling-configs": "^0.3.3",
85
85
  "@types/chai": "^5.2.3",
86
86
  "@types/mocha": "^10.0.10",
87
87
  "@types/node": "^24.0.0",