@antelopejs/dms-lang 0.0.6 → 0.1.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.
- package/README.md +12 -6
- package/dist/pages/actions.d.ts +7 -0
- package/dist/pages/actions.js +15 -0
- package/dist/pages/actions.js.map +1 -0
- package/dist/pages/component-action.d.ts +2 -0
- package/dist/pages/component-action.js +10 -0
- package/dist/pages/component-action.js.map +1 -0
- package/dist/pages/header-actions.d.ts +9 -0
- package/dist/pages/header-actions.js +146 -0
- package/dist/pages/header-actions.js.map +1 -0
- package/dist/pages/index.d.ts +6 -0
- package/dist/pages/index.js +6 -0
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/language.d.ts +10 -0
- package/dist/pages/language.js +89 -0
- package/dist/pages/language.js.map +1 -0
- package/dist/pages/languages-table.d.ts +2 -0
- package/dist/pages/languages-table.js +120 -0
- package/dist/pages/languages-table.js.map +1 -0
- package/dist/pages/module.d.ts +7 -1
- package/dist/pages/module.js +28 -2
- package/dist/pages/module.js.map +1 -1
- package/dist/pages/overview.d.ts +2 -1
- package/dist/pages/overview.js +83 -8
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/page-actions.d.ts +6 -0
- package/dist/pages/page-actions.js +10 -0
- package/dist/pages/page-actions.js.map +1 -0
- package/dist/pages/quick-actions.d.ts +1 -0
- package/dist/pages/quick-actions.js +56 -0
- package/dist/pages/quick-actions.js.map +1 -0
- package/dist/pages/translations.d.ts +7 -1
- package/dist/pages/translations.js +47 -10
- package/dist/pages/translations.js.map +1 -1
- package/dist/pages/workspace-guard.d.ts +1 -0
- package/dist/pages/workspace-guard.js +35 -0
- package/dist/pages/workspace-guard.js.map +1 -0
- package/dist/pages/workspace.d.ts +18 -0
- package/dist/pages/workspace.js +162 -0
- package/dist/pages/workspace.js.map +1 -0
- package/dist/pages/workspaces.d.ts +14 -0
- package/dist/pages/workspaces.js +88 -0
- package/dist/pages/workspaces.js.map +1 -0
- package/dist/routes/publicLocales.d.ts +3 -2
- package/dist/routes/publicLocales.js +39 -18
- package/dist/routes/publicLocales.js.map +1 -1
- package/dist/routes/translations.d.ts +59 -63
- package/dist/routes/translations.js +400 -119
- package/dist/routes/translations.js.map +1 -1
- package/dist/utils/announce.d.ts +9 -0
- package/dist/utils/announce.js +29 -0
- package/dist/utils/announce.js.map +1 -0
- package/dist/utils/blocks.d.ts +8 -0
- package/dist/utils/blocks.js +213 -0
- package/dist/utils/blocks.js.map +1 -0
- package/dist/utils/body.d.ts +1 -0
- package/dist/utils/body.js +21 -0
- package/dist/utils/body.js.map +1 -0
- package/dist/utils/cache.d.ts +3 -0
- package/dist/utils/cache.js +32 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/catalog.d.ts +7 -0
- package/dist/utils/catalog.js +62 -0
- package/dist/utils/catalog.js.map +1 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.js +10 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/coverage.d.ts +2 -0
- package/dist/utils/coverage.js +11 -0
- package/dist/utils/coverage.js.map +1 -0
- package/dist/utils/dialogs.d.ts +7 -0
- package/dist/utils/dialogs.js +103 -0
- package/dist/utils/dialogs.js.map +1 -0
- package/dist/utils/errors.d.ts +40 -0
- package/dist/utils/errors.js +60 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/export.d.ts +17 -0
- package/dist/utils/export.js +129 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/json.d.ts +10 -1
- package/dist/utils/json.js +127 -19
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/key-stores.d.ts +3 -0
- package/dist/utils/key-stores.js +24 -0
- package/dist/utils/key-stores.js.map +1 -0
- package/dist/utils/keys.d.ts +23 -0
- package/dist/utils/keys.js +252 -0
- package/dist/utils/keys.js.map +1 -0
- package/dist/utils/languages.d.ts +27 -0
- package/dist/utils/languages.js +121 -0
- package/dist/utils/languages.js.map +1 -0
- package/dist/utils/locale-codes.d.ts +5 -0
- package/dist/utils/locale-codes.js +56 -0
- package/dist/utils/locale-codes.js.map +1 -0
- package/dist/utils/locale-discovery.d.ts +1 -0
- package/dist/utils/locale-discovery.js +19 -1
- package/dist/utils/locale-discovery.js.map +1 -1
- package/dist/utils/message-check.d.ts +1 -0
- package/dist/utils/message-check.js +93 -0
- package/dist/utils/message-check.js.map +1 -0
- package/dist/utils/message-syntax.d.ts +6 -0
- package/dist/utils/message-syntax.js +38 -0
- package/dist/utils/message-syntax.js.map +1 -0
- package/dist/utils/namespaces.d.ts +12 -0
- package/dist/utils/namespaces.js +52 -0
- package/dist/utils/namespaces.js.map +1 -0
- package/dist/utils/notices.d.ts +4 -0
- package/dist/utils/notices.js +60 -0
- package/dist/utils/notices.js.map +1 -0
- package/dist/utils/own.d.ts +2 -3
- package/dist/utils/own.js +17 -57
- package/dist/utils/own.js.map +1 -1
- package/dist/utils/public-url.d.ts +8 -0
- package/dist/utils/public-url.js +87 -0
- package/dist/utils/public-url.js.map +1 -0
- package/dist/utils/registry.d.ts +3 -1
- package/dist/utils/registry.js +26 -10
- package/dist/utils/registry.js.map +1 -1
- package/dist/utils/resolve.d.ts +18 -15
- package/dist/utils/resolve.js +98 -151
- package/dist/utils/resolve.js.map +1 -1
- package/dist/utils/review.d.ts +5 -0
- package/dist/utils/review.js +64 -0
- package/dist/utils/review.js.map +1 -0
- package/dist/utils/snippets.d.ts +7 -0
- package/dist/utils/snippets.js +129 -0
- package/dist/utils/snippets.js.map +1 -0
- package/dist/utils/summary.d.ts +23 -0
- package/dist/utils/summary.js +65 -0
- package/dist/utils/summary.js.map +1 -0
- package/dist/utils/tree.d.ts +2 -17
- package/dist/utils/tree.js +21 -126
- package/dist/utils/tree.js.map +1 -1
- package/dist/utils/workspaces.d.ts +45 -15
- package/dist/utils/workspaces.js +256 -164
- package/dist/utils/workspaces.js.map +1 -1
- package/dist/validation/key.schema.d.ts +71 -0
- package/dist/validation/key.schema.js +67 -0
- package/dist/validation/key.schema.js.map +1 -0
- package/dist/validation/query.schema.d.ts +17 -0
- package/dist/validation/query.schema.js +44 -0
- package/dist/validation/query.schema.js.map +1 -0
- package/dist/validation/validate.d.ts +2 -0
- package/dist/validation/validate.js +24 -0
- package/dist/validation/validate.js.map +1 -0
- package/dist/validation/workspace.schema.d.ts +145 -0
- package/dist/validation/workspace.schema.js +83 -0
- package/dist/validation/workspace.schema.js.map +1 -0
- package/frontend-vue/app/build/components/KeyAddModal.vue +340 -0
- package/frontend-vue/app/build/components/KeyEditorDrawer.vue +951 -0
- package/frontend-vue/app/build/components/KeyRenameModal.vue +172 -0
- package/frontend-vue/app/build/components/LanguageAddModal.vue +199 -0
- package/frontend-vue/app/build/components/LanguagePicker.vue +233 -0
- package/frontend-vue/app/build/components/LocaleTile.vue +52 -0
- package/frontend-vue/app/build/components/PlaceholderText.vue +42 -0
- package/frontend-vue/app/build/components/ShortcutKbds.vue +22 -0
- package/frontend-vue/app/build/components/WorkspaceCreateModal.vue +193 -0
- package/frontend-vue/app/build/components/WorkspaceRenameModal.vue +107 -0
- package/frontend-vue/app/build/components/form/FormFieldRow.vue +70 -0
- package/frontend-vue/app/build/components/form/FormRows.vue +25 -0
- package/frontend-vue/app/build/components/form/WorkspaceDetailsFields.vue +44 -0
- package/frontend-vue/app/build/components/matrix/MatrixCell.vue +488 -0
- package/frontend-vue/app/build/components/matrix/MatrixColumns.vue +177 -0
- package/frontend-vue/app/build/components/matrix/MatrixGroupHeader.vue +57 -0
- package/frontend-vue/app/build/components/matrix/MatrixKeyCell.vue +83 -0
- package/frontend-vue/app/build/components/matrix/MatrixToolbar.vue +167 -0
- package/frontend-vue/app/build/components/queue/QueueActions.vue +60 -0
- package/frontend-vue/app/build/components/queue/QueueDone.vue +185 -0
- package/frontend-vue/app/build/components/queue/QueueEditor.vue +374 -0
- package/frontend-vue/app/build/components/queue/QueueHeader.vue +162 -0
- package/frontend-vue/app/build/components/queue/QueueUpNext.vue +61 -0
- package/frontend-vue/app/build/composables/useCellEditor.ts +324 -0
- package/frontend-vue/app/build/composables/useCellMoves.ts +155 -0
- package/frontend-vue/app/build/composables/useCellSaves.ts +339 -0
- package/frontend-vue/app/build/composables/useKeyPanel.ts +284 -0
- package/frontend-vue/app/build/composables/useKeySaves.ts +280 -0
- package/frontend-vue/app/build/composables/useMatrixFilters.ts +213 -0
- package/frontend-vue/app/build/composables/useMatrixRows.ts +104 -0
- package/frontend-vue/app/build/composables/useMatrixView.ts +181 -0
- package/frontend-vue/app/build/composables/useQueueContext.ts +31 -0
- package/frontend-vue/app/build/composables/useQueueEditing.ts +53 -0
- package/frontend-vue/app/build/composables/useQueueOrphans.ts +54 -0
- package/frontend-vue/app/build/composables/useQueueSave.ts +290 -0
- package/frontend-vue/app/build/composables/useQueueShortcuts.ts +106 -0
- package/frontend-vue/app/build/composables/useQueueToasts.ts +99 -0
- package/frontend-vue/app/components/LanguageNamespaces.vue +77 -0
- package/frontend-vue/app/components/NamespaceCoverage.vue +222 -0
- package/frontend-vue/app/components/TranslationMatrix.vue +809 -0
- package/frontend-vue/app/components/TranslationQueue.vue +212 -0
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +81 -0
- package/frontend-vue/app/components/WorkspaceGeneral.vue +232 -0
- package/frontend-vue/app/components/WorkspaceList.vue +454 -0
- package/frontend-vue/app/components/WorkspaceScope.vue +384 -0
- package/frontend-vue/app/composables/translation/useFirstRun.ts +8 -0
- package/frontend-vue/app/composables/translation/useI18nWorkspaces.ts +221 -133
- package/frontend-vue/app/composables/translation/useKeyActions.ts +224 -0
- package/frontend-vue/app/composables/translation/useLangFormat.ts +10 -0
- package/frontend-vue/app/composables/translation/useLangLinks.ts +80 -0
- package/frontend-vue/app/composables/translation/useLanguageActions.ts +159 -0
- package/frontend-vue/app/composables/translation/useLanguageQueue.ts +232 -0
- package/frontend-vue/app/composables/translation/useLocaleNames.ts +166 -0
- package/frontend-vue/app/composables/translation/useMutationToast.ts +51 -17
- package/frontend-vue/app/composables/translation/useQueueDrafts.ts +115 -0
- package/frontend-vue/app/composables/translation/useQueueSession.ts +182 -0
- package/frontend-vue/app/composables/translation/useServedConfirm.ts +152 -0
- package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +259 -0
- package/frontend-vue/app/composables/translation/useWorkspaceContext.ts +46 -15
- package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +322 -70
- package/frontend-vue/app/composables/translation/useWorkspaceNameCheck.ts +55 -0
- package/frontend-vue/app/composables/translation/useWorkspaceRoute.ts +129 -0
- package/frontend-vue/app/config/shortcuts-registry.ts +72 -0
- package/frontend-vue/app/types/lang.ts +130 -0
- package/frontend-vue/app/utils/boundedCache.ts +22 -0
- package/frontend-vue/app/utils/download.ts +16 -0
- package/frontend-vue/app/utils/keySaveErrors.ts +61 -0
- package/frontend-vue/app/utils/keySaves.ts +108 -0
- package/frontend-vue/app/utils/languages.ts +272 -0
- package/frontend-vue/app/utils/matrixExport.ts +47 -0
- package/frontend-vue/app/utils/queueDrafts.ts +115 -0
- package/frontend-vue/app/utils/queuePass.ts +145 -0
- package/frontend-vue/app/utils/queueView.ts +22 -0
- package/frontend-vue/app/utils/shortcuts.ts +75 -0
- package/frontend-vue/app/utils/translations.ts +756 -0
- package/frontend-vue/app/utils/workspaceBackup.ts +119 -0
- package/frontend-vue/app/utils/workspaces.ts +45 -0
- package/frontend-vue/dms.frontend.build.ts +5 -0
- package/frontend-vue/dms.frontend.ts +9 -20
- package/frontend-vue/i18n/locales/lang-en-GB.json +792 -69
- package/frontend-vue/i18n/locales/lang-fr-FR.json +792 -69
- package/frontend-vue/package.json +10 -5
- package/package.json +10 -8
- package/dist/utils/mutations.d.ts +0 -3
- package/dist/utils/mutations.js +0 -35
- package/dist/utils/mutations.js.map +0 -1
- package/frontend-vue/app/build/components/pages/lang/TranslationMatrix.vue +0 -284
- package/frontend-vue/app/components/LanguageAddModal.vue +0 -78
- package/frontend-vue/app/components/WorkspaceEndpoint.vue +0 -29
- package/frontend-vue/app/components/WorkspaceSelector.vue +0 -180
- package/frontend-vue/app/components/WorkspaceStatus.vue +0 -24
- package/frontend-vue/app/composables/translation/useLanguageCatalog.ts +0 -90
- package/frontend-vue/app/composables/translation/useLocaleMeta.ts +0 -18
- package/frontend-vue/app/composables/translation/useTranslationProgress.ts +0 -73
- package/frontend-vue/app/custom-pages/lang/overview.vue +0 -397
- package/frontend-vue/app/custom-pages/lang/translations.vue +0 -498
- package/frontend-vue/app/plugins/workspace-sidebar-widget.ts +0 -12
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
isValidKeyPath,
|
|
4
|
+
keyPathConflict,
|
|
5
|
+
type KeyPathConflict,
|
|
6
|
+
} from '../../utils/translations'
|
|
7
|
+
import FormFieldRow from './form/FormFieldRow.vue'
|
|
8
|
+
import FormRows from './form/FormRows.vue'
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
workspace: string
|
|
12
|
+
path: string
|
|
13
|
+
languageCount: number
|
|
14
|
+
existingKeys: string[]
|
|
15
|
+
/** Project files only: the keys the installed modules provide. */
|
|
16
|
+
moduleKeys?: string[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CONFLICT_LABELS: Record<KeyPathConflict['kind'], string> = {
|
|
20
|
+
exists: 'dms_lang.key_add.path_taken',
|
|
21
|
+
namespace: 'dms_lang.key_add.path_namespace_conflict',
|
|
22
|
+
leafParent: 'dms_lang.key_add.path_parent_conflict',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const MODULE_CONFLICT_LABELS: Record<KeyPathConflict['kind'], string> = {
|
|
26
|
+
exists: 'dms_lang.key_rename.module_key',
|
|
27
|
+
namespace: 'dms_lang.key_add.module_namespace',
|
|
28
|
+
leafParent: 'dms_lang.key_add.module_parent',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface Emits {
|
|
32
|
+
close: [newPath: string | null]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const props = defineProps<Props>()
|
|
36
|
+
const emit = defineEmits<Emits>()
|
|
37
|
+
|
|
38
|
+
const { t } = useI18n()
|
|
39
|
+
const { errorMessage } = useMutationToast()
|
|
40
|
+
const { renameKey } = useI18nWorkspaces()
|
|
41
|
+
const { applyRow } = useWorkspaceFlat()
|
|
42
|
+
|
|
43
|
+
const isOpen = ref(true)
|
|
44
|
+
const newPath = ref(props.path)
|
|
45
|
+
const isSubmitting = ref(false)
|
|
46
|
+
const submitError = ref('')
|
|
47
|
+
|
|
48
|
+
const trimmed = computed(() => newPath.value.trim())
|
|
49
|
+
const otherKeys = computed(() =>
|
|
50
|
+
props.existingKeys.filter((key) => key !== props.path),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
function conflictText(
|
|
54
|
+
found: KeyPathConflict | null,
|
|
55
|
+
labels: Record<KeyPathConflict['kind'], string>,
|
|
56
|
+
): string {
|
|
57
|
+
if (!found) return ''
|
|
58
|
+
return t(
|
|
59
|
+
labels[found.kind],
|
|
60
|
+
{
|
|
61
|
+
path: trimmed.value,
|
|
62
|
+
parent: found.keys[0],
|
|
63
|
+
example: found.keys[0],
|
|
64
|
+
count: found.keys.length,
|
|
65
|
+
},
|
|
66
|
+
found.keys.length,
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const error = computed(() => {
|
|
71
|
+
if (trimmed.value === props.path) return ''
|
|
72
|
+
if (!isValidKeyPath(trimmed.value)) return t('dms_lang.key_add.path_invalid')
|
|
73
|
+
return (
|
|
74
|
+
conflictText(
|
|
75
|
+
keyPathConflict(trimmed.value, otherKeys.value),
|
|
76
|
+
CONFLICT_LABELS,
|
|
77
|
+
) ||
|
|
78
|
+
conflictText(
|
|
79
|
+
keyPathConflict(trimmed.value, props.moduleKeys ?? []),
|
|
80
|
+
MODULE_CONFLICT_LABELS,
|
|
81
|
+
) ||
|
|
82
|
+
submitError.value
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
const isValid = computed(() => trimmed.value !== props.path && !error.value)
|
|
86
|
+
|
|
87
|
+
watch(trimmed, () => (submitError.value = ''))
|
|
88
|
+
|
|
89
|
+
function close(value: string | null) {
|
|
90
|
+
isOpen.value = false
|
|
91
|
+
emit('close', value)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function submit() {
|
|
95
|
+
if (!isValid.value || isSubmitting.value) return
|
|
96
|
+
isSubmitting.value = true
|
|
97
|
+
const target = trimmed.value
|
|
98
|
+
try {
|
|
99
|
+
const response = await renameKey(props.workspace, props.path, target)
|
|
100
|
+
applyRow(props.workspace, props.path, response)
|
|
101
|
+
close(target)
|
|
102
|
+
} catch (failure) {
|
|
103
|
+
submitError.value = errorMessage(failure)
|
|
104
|
+
} finally {
|
|
105
|
+
isSubmitting.value = false
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<template>
|
|
111
|
+
<UModal
|
|
112
|
+
v-model:open="isOpen"
|
|
113
|
+
:title="$t('dms_lang.key_rename.title')"
|
|
114
|
+
:description="$t('dms_lang.key_rename.description', props.languageCount)"
|
|
115
|
+
:ui="{ content: 'sm:max-w-lg' }"
|
|
116
|
+
@update:open="(open: boolean) => !open && close(null)"
|
|
117
|
+
>
|
|
118
|
+
<template #body>
|
|
119
|
+
<form novalidate @submit.prevent="submit">
|
|
120
|
+
<FormRows has-required>
|
|
121
|
+
<FormFieldRow :label="$t('dms_lang.key_rename.current')">
|
|
122
|
+
<template #default="{ id }">
|
|
123
|
+
<DmsInputText
|
|
124
|
+
:id="id"
|
|
125
|
+
:model-value="props.path"
|
|
126
|
+
disabled
|
|
127
|
+
class="w-full"
|
|
128
|
+
:ui="{ base: 'font-mono' }"
|
|
129
|
+
/>
|
|
130
|
+
</template>
|
|
131
|
+
</FormFieldRow>
|
|
132
|
+
<FormFieldRow
|
|
133
|
+
:label="$t('dms_lang.key_rename.new')"
|
|
134
|
+
:help="
|
|
135
|
+
error
|
|
136
|
+
? undefined
|
|
137
|
+
: $t('dms_lang.key_rename.help', { path: props.path })
|
|
138
|
+
"
|
|
139
|
+
:error="error || null"
|
|
140
|
+
required
|
|
141
|
+
>
|
|
142
|
+
<template #default="{ id }">
|
|
143
|
+
<DmsInputText
|
|
144
|
+
:id="id"
|
|
145
|
+
v-model="newPath"
|
|
146
|
+
autofocus
|
|
147
|
+
class="w-full"
|
|
148
|
+
:ui="{ base: 'font-mono' }"
|
|
149
|
+
/>
|
|
150
|
+
</template>
|
|
151
|
+
</FormFieldRow>
|
|
152
|
+
</FormRows>
|
|
153
|
+
</form>
|
|
154
|
+
</template>
|
|
155
|
+
<template #footer>
|
|
156
|
+
<div class="flex w-full justify-end gap-2">
|
|
157
|
+
<UButton
|
|
158
|
+
color="neutral"
|
|
159
|
+
variant="outline"
|
|
160
|
+
:label="$t('dms_lang.actions.cancel')"
|
|
161
|
+
@click="close(null)"
|
|
162
|
+
/>
|
|
163
|
+
<UButton
|
|
164
|
+
:loading="isSubmitting"
|
|
165
|
+
:disabled="!isValid"
|
|
166
|
+
:label="$t('dms_lang.key_rename.submit')"
|
|
167
|
+
@click="submit"
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
</template>
|
|
171
|
+
</UModal>
|
|
172
|
+
</template>
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import LanguagePicker from './LanguagePicker.vue'
|
|
3
|
+
import { canonicalLocale, hasSubtags, languageOf } from '../../utils/languages'
|
|
4
|
+
|
|
5
|
+
interface Emits {
|
|
6
|
+
close: [added: boolean]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
workspace: string
|
|
11
|
+
existing: string[]
|
|
12
|
+
baseName: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const LOCALE_EXISTS = 'locale_exists'
|
|
16
|
+
|
|
17
|
+
const props = defineProps<Props>()
|
|
18
|
+
const emit = defineEmits<Emits>()
|
|
19
|
+
|
|
20
|
+
const { t } = useI18n()
|
|
21
|
+
const toast = useToast()
|
|
22
|
+
const { addLocale, workspaces } = useI18nWorkspaces()
|
|
23
|
+
const { reportFailure } = useMutationToast()
|
|
24
|
+
const { findLanguages, fullName } = useLocaleNames()
|
|
25
|
+
const { refresh } = useWorkspaceFlat()
|
|
26
|
+
|
|
27
|
+
const isOpen = ref(true)
|
|
28
|
+
const search = ref('')
|
|
29
|
+
const selected = ref('')
|
|
30
|
+
const isSubmitting = ref(false)
|
|
31
|
+
/** A language picked here that another tab added meanwhile. */
|
|
32
|
+
const addedElsewhere = ref('')
|
|
33
|
+
|
|
34
|
+
const liveCodes = computed(
|
|
35
|
+
() =>
|
|
36
|
+
workspaces.value
|
|
37
|
+
.find((workspace) => workspace.id === props.workspace)
|
|
38
|
+
?.locales.map((entry) => entry.code) ?? props.existing,
|
|
39
|
+
)
|
|
40
|
+
const existingCodes = computed(
|
|
41
|
+
() => new Set(liveCodes.value.map((code) => canonicalLocale(code) ?? code)),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const options = computed(() => findLanguages(search.value))
|
|
45
|
+
const selectedOption = computed(
|
|
46
|
+
() =>
|
|
47
|
+
options.value.find(
|
|
48
|
+
(option) =>
|
|
49
|
+
option.code === selected.value && !existingCodes.value.has(option.code),
|
|
50
|
+
) ?? null,
|
|
51
|
+
)
|
|
52
|
+
const sameLanguage = computed(() => {
|
|
53
|
+
const code = selectedOption.value?.code
|
|
54
|
+
if (!code) return []
|
|
55
|
+
return [...existingCodes.value].filter(
|
|
56
|
+
(other) => languageOf(other) === languageOf(code),
|
|
57
|
+
)
|
|
58
|
+
})
|
|
59
|
+
const isInvalidCode = computed(
|
|
60
|
+
() => !options.value.length && hasSubtags(search.value),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
watch(existingCodes, (codes) => {
|
|
64
|
+
if (!selected.value || !codes.has(selected.value)) return
|
|
65
|
+
addedElsewhere.value = selected.value
|
|
66
|
+
selected.value = ''
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
watch(selected, (code) => {
|
|
70
|
+
if (code) addedElsewhere.value = ''
|
|
71
|
+
})
|
|
72
|
+
async function submit() {
|
|
73
|
+
if (!selectedOption.value || isSubmitting.value) return
|
|
74
|
+
isSubmitting.value = true
|
|
75
|
+
const code = selectedOption.value.code
|
|
76
|
+
try {
|
|
77
|
+
await addLocale(props.workspace, { code })
|
|
78
|
+
close(true)
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (serverErrorCode(error) === LOCALE_EXISTS) {
|
|
81
|
+
await closeAsAdded(code)
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
reportFailure(error)
|
|
85
|
+
isSubmitting.value = false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Another tab added the language first: nothing left to do here. */
|
|
90
|
+
async function closeAsAdded(code: string) {
|
|
91
|
+
toast.add({
|
|
92
|
+
title: t('dms_lang.language_add.exists_title', {
|
|
93
|
+
name: fullName(code),
|
|
94
|
+
code,
|
|
95
|
+
}),
|
|
96
|
+
description: t('dms_lang.language_add.exists'),
|
|
97
|
+
color: 'info',
|
|
98
|
+
icon: 'i-ph-info',
|
|
99
|
+
})
|
|
100
|
+
close(false)
|
|
101
|
+
await refresh()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function close(added: boolean) {
|
|
105
|
+
isOpen.value = false
|
|
106
|
+
emit('close', added)
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<template>
|
|
111
|
+
<UModal
|
|
112
|
+
v-model:open="isOpen"
|
|
113
|
+
:title="$t('dms_lang.language_add.title', { workspace: props.workspace })"
|
|
114
|
+
:description="
|
|
115
|
+
$t('dms_lang.language_add.description', { base: props.baseName })
|
|
116
|
+
"
|
|
117
|
+
:ui="{ content: 'sm:max-w-lg' }"
|
|
118
|
+
@update:open="(open: boolean) => !open && close(false)"
|
|
119
|
+
>
|
|
120
|
+
<template #body>
|
|
121
|
+
<div class="space-y-3">
|
|
122
|
+
<LanguagePicker
|
|
123
|
+
v-model="selected"
|
|
124
|
+
v-model:search="search"
|
|
125
|
+
:options="options"
|
|
126
|
+
:taken="[...existingCodes]"
|
|
127
|
+
is-open
|
|
128
|
+
autofocus
|
|
129
|
+
@submit="submit"
|
|
130
|
+
>
|
|
131
|
+
<template #empty>
|
|
132
|
+
{{
|
|
133
|
+
isInvalidCode
|
|
134
|
+
? $t('dms_lang.language_add.invalid_code', {
|
|
135
|
+
code: search.trim(),
|
|
136
|
+
})
|
|
137
|
+
: $t('dms_lang.language_add.no_match')
|
|
138
|
+
}}
|
|
139
|
+
</template>
|
|
140
|
+
</LanguagePicker>
|
|
141
|
+
<p
|
|
142
|
+
v-if="addedElsewhere"
|
|
143
|
+
role="status"
|
|
144
|
+
class="text-warning flex items-start gap-2 text-xs"
|
|
145
|
+
>
|
|
146
|
+
<UIcon name="i-ph-warning" class="mt-0.5 size-3.5 shrink-0" />
|
|
147
|
+
{{
|
|
148
|
+
$t('dms_lang.language_add.added_elsewhere', {
|
|
149
|
+
name: fullName(addedElsewhere),
|
|
150
|
+
code: addedElsewhere,
|
|
151
|
+
})
|
|
152
|
+
}}
|
|
153
|
+
</p>
|
|
154
|
+
<p
|
|
155
|
+
v-else-if="selectedOption && sameLanguage.length"
|
|
156
|
+
class="text-warning flex items-start gap-2 text-xs"
|
|
157
|
+
>
|
|
158
|
+
<UIcon name="i-ph-warning" class="mt-0.5 size-3.5 shrink-0" />
|
|
159
|
+
{{
|
|
160
|
+
$t('dms_lang.language_add.same_language', {
|
|
161
|
+
codes: sameLanguage.join(', '),
|
|
162
|
+
name: selectedOption.name,
|
|
163
|
+
code: selectedOption.code,
|
|
164
|
+
})
|
|
165
|
+
}}
|
|
166
|
+
</p>
|
|
167
|
+
<p v-else class="text-muted flex items-start gap-2 text-xs">
|
|
168
|
+
<UIcon name="i-ph-info" class="mt-0.5 size-3.5 shrink-0" />
|
|
169
|
+
{{ $t('dms_lang.language_add.any_code') }}
|
|
170
|
+
</p>
|
|
171
|
+
</div>
|
|
172
|
+
</template>
|
|
173
|
+
<template #footer>
|
|
174
|
+
<div class="flex w-full justify-end gap-2">
|
|
175
|
+
<UButton
|
|
176
|
+
color="neutral"
|
|
177
|
+
variant="outline"
|
|
178
|
+
:label="$t('dms_lang.actions.cancel')"
|
|
179
|
+
:disabled="isSubmitting"
|
|
180
|
+
@click="close(false)"
|
|
181
|
+
/>
|
|
182
|
+
<UButton
|
|
183
|
+
icon="i-ph-plus"
|
|
184
|
+
:loading="isSubmitting"
|
|
185
|
+
:disabled="!selectedOption"
|
|
186
|
+
:label="
|
|
187
|
+
selectedOption
|
|
188
|
+
? $t('dms_lang.language_add.submit_named', {
|
|
189
|
+
name: selectedOption.name,
|
|
190
|
+
code: selectedOption.code,
|
|
191
|
+
})
|
|
192
|
+
: $t('dms_lang.language_add.submit')
|
|
193
|
+
"
|
|
194
|
+
@click="submit"
|
|
195
|
+
/>
|
|
196
|
+
</div>
|
|
197
|
+
</template>
|
|
198
|
+
</UModal>
|
|
199
|
+
</template>
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { SelectMenuItem } from '@nuxt/ui'
|
|
3
|
+
import { typedLocaleCode, type LanguageOption } from '../../utils/languages'
|
|
4
|
+
import LocaleTile from './LocaleTile.vue'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** The languages offered for the search, best first. */
|
|
8
|
+
options: LanguageOption[]
|
|
9
|
+
/** Codes offered but not to pick again: listed apart, disabled. */
|
|
10
|
+
taken?: string[]
|
|
11
|
+
/** The id the field's label points to. */
|
|
12
|
+
id?: string
|
|
13
|
+
placeholder?: string
|
|
14
|
+
autofocus?: boolean
|
|
15
|
+
/** A search field over a list always open, instead of a menu. */
|
|
16
|
+
isOpen?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Emits {
|
|
20
|
+
/** Enter or a double click on a language of the open list. */
|
|
21
|
+
submit: []
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface Slots {
|
|
25
|
+
/** What the list says when the search finds nothing. */
|
|
26
|
+
empty?: () => unknown
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const STEP_KEYS: Record<string, number> = { ArrowDown: 1, ArrowUp: -1 }
|
|
30
|
+
const LISTBOX_ID = 'language-picker-options'
|
|
31
|
+
|
|
32
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
33
|
+
taken: () => [],
|
|
34
|
+
id: undefined,
|
|
35
|
+
placeholder: undefined,
|
|
36
|
+
autofocus: false,
|
|
37
|
+
isOpen: false,
|
|
38
|
+
})
|
|
39
|
+
const emit = defineEmits<Emits>()
|
|
40
|
+
const code = defineModel<string>({ default: '' })
|
|
41
|
+
const search = defineModel<string>('search', { default: '' })
|
|
42
|
+
defineSlots<Slots>()
|
|
43
|
+
|
|
44
|
+
const { t } = useI18n()
|
|
45
|
+
const { fullName } = useLocaleNames()
|
|
46
|
+
|
|
47
|
+
const takenCodes = computed(() => new Set(props.taken))
|
|
48
|
+
const free = computed(() =>
|
|
49
|
+
props.options.filter((option) => !takenCodes.value.has(option.code)),
|
|
50
|
+
)
|
|
51
|
+
const added = computed(() =>
|
|
52
|
+
props.options.filter((option) => takenCodes.value.has(option.code)),
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
function detailOf(option: LanguageOption): string {
|
|
56
|
+
return option.isUnknown
|
|
57
|
+
? t('dms_lang.language_add.unknown')
|
|
58
|
+
: option.localName
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function itemOf(option: LanguageOption, isTaken: boolean): SelectMenuItem {
|
|
62
|
+
return {
|
|
63
|
+
label: option.name,
|
|
64
|
+
value: option.code,
|
|
65
|
+
description: detailOf(option),
|
|
66
|
+
disabled: isTaken,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The languages to pick, then the ones already there, under their own label. */
|
|
71
|
+
const items = computed<SelectMenuItem[][]>(() => {
|
|
72
|
+
const groups = [free.value.map((option) => itemOf(option, false))]
|
|
73
|
+
if (!added.value.length) return groups
|
|
74
|
+
const label = {
|
|
75
|
+
type: 'label' as const,
|
|
76
|
+
label: t('dms_lang.language_add.already_added'),
|
|
77
|
+
}
|
|
78
|
+
return [...groups, [label, ...added.value.map((o) => itemOf(o, true))]]
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
function optionId(value: string): string {
|
|
82
|
+
return `${LISTBOX_ID}-${value}`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Typing a code the list offers picks it. */
|
|
86
|
+
watch(search, () => {
|
|
87
|
+
if (!props.isOpen) return
|
|
88
|
+
const exact = typedLocaleCode(search.value)
|
|
89
|
+
const match = free.value.find((option) => option.code === exact)
|
|
90
|
+
code.value = match && !match.isUnknown ? match.code : ''
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
function step(event: KeyboardEvent) {
|
|
94
|
+
const delta = STEP_KEYS[event.key]
|
|
95
|
+
const list = free.value
|
|
96
|
+
if (!delta || !list.length) return
|
|
97
|
+
event.preventDefault()
|
|
98
|
+
const index = list.findIndex((option) => option.code === code.value)
|
|
99
|
+
const start = delta > 0 ? 0 : list.length - 1
|
|
100
|
+
const next = index < 0 ? start : index + delta
|
|
101
|
+
code.value = list[(next + list.length) % list.length]?.code ?? ''
|
|
102
|
+
document
|
|
103
|
+
.getElementById(optionId(code.value))
|
|
104
|
+
?.scrollIntoView({ block: 'nearest' })
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<template>
|
|
109
|
+
<div v-if="props.isOpen" class="space-y-3">
|
|
110
|
+
<DmsInputText
|
|
111
|
+
:id="props.id"
|
|
112
|
+
v-model="search"
|
|
113
|
+
icon="i-ph-magnifying-glass"
|
|
114
|
+
:autofocus="props.autofocus"
|
|
115
|
+
class="w-full"
|
|
116
|
+
role="combobox"
|
|
117
|
+
aria-autocomplete="list"
|
|
118
|
+
:aria-expanded="true"
|
|
119
|
+
:aria-controls="LISTBOX_ID"
|
|
120
|
+
:aria-activedescendant="code ? optionId(code) : undefined"
|
|
121
|
+
:placeholder="$t('dms_lang.language_add.search')"
|
|
122
|
+
@keydown.enter.prevent="emit('submit')"
|
|
123
|
+
@keydown="step"
|
|
124
|
+
/>
|
|
125
|
+
<div
|
|
126
|
+
:id="LISTBOX_ID"
|
|
127
|
+
role="listbox"
|
|
128
|
+
class="max-h-80 space-y-0.5 overflow-y-auto"
|
|
129
|
+
>
|
|
130
|
+
<DmsEyebrow
|
|
131
|
+
v-if="free.length"
|
|
132
|
+
:label="$t('dms_lang.language_add.suggested', free.length)"
|
|
133
|
+
size="xs"
|
|
134
|
+
class="px-2 pt-1 pb-1.5"
|
|
135
|
+
/>
|
|
136
|
+
<button
|
|
137
|
+
v-for="option in free"
|
|
138
|
+
:id="optionId(option.code)"
|
|
139
|
+
:key="option.code"
|
|
140
|
+
type="button"
|
|
141
|
+
role="option"
|
|
142
|
+
:aria-selected="option.code === code"
|
|
143
|
+
class="flex w-full items-center gap-3 rounded-md px-2 py-1.5 text-left transition-colors"
|
|
144
|
+
:class="
|
|
145
|
+
option.code === code
|
|
146
|
+
? 'bg-primary/10 text-highlighted'
|
|
147
|
+
: 'hover:bg-elevated/60'
|
|
148
|
+
"
|
|
149
|
+
@click="code = option.code"
|
|
150
|
+
@dblclick="emit('submit')"
|
|
151
|
+
>
|
|
152
|
+
<LocaleTile :code="option.code" />
|
|
153
|
+
<span class="min-w-0 flex-1">
|
|
154
|
+
<span class="text-highlighted block truncate text-sm">
|
|
155
|
+
{{ option.name }}
|
|
156
|
+
</span>
|
|
157
|
+
<span class="text-dimmed block truncate text-xs">
|
|
158
|
+
{{ detailOf(option) }}
|
|
159
|
+
</span>
|
|
160
|
+
</span>
|
|
161
|
+
<span class="text-dimmed font-mono text-xs">{{ option.code }}</span>
|
|
162
|
+
<UIcon
|
|
163
|
+
v-if="option.code === code"
|
|
164
|
+
name="i-ph-check"
|
|
165
|
+
class="text-primary size-4"
|
|
166
|
+
/>
|
|
167
|
+
</button>
|
|
168
|
+
<template v-if="added.length">
|
|
169
|
+
<DmsEyebrow
|
|
170
|
+
:label="$t('dms_lang.language_add.already_added')"
|
|
171
|
+
size="xs"
|
|
172
|
+
class="px-2 pt-3 pb-1.5"
|
|
173
|
+
/>
|
|
174
|
+
<div
|
|
175
|
+
v-for="option in added"
|
|
176
|
+
:key="option.code"
|
|
177
|
+
role="option"
|
|
178
|
+
aria-disabled="true"
|
|
179
|
+
:aria-selected="false"
|
|
180
|
+
class="flex items-center gap-3 px-2 py-1.5 opacity-60"
|
|
181
|
+
>
|
|
182
|
+
<LocaleTile :code="option.code" />
|
|
183
|
+
<span class="text-highlighted flex-1 truncate text-sm">
|
|
184
|
+
{{ option.name }}
|
|
185
|
+
</span>
|
|
186
|
+
<span class="text-dimmed font-mono text-xs">{{ option.code }}</span>
|
|
187
|
+
<DmsStatusPill
|
|
188
|
+
dot="none"
|
|
189
|
+
tone="neutral"
|
|
190
|
+
size="sm"
|
|
191
|
+
:label="$t('dms_lang.language_add.added')"
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
</template>
|
|
195
|
+
<p
|
|
196
|
+
v-if="!props.options.length"
|
|
197
|
+
class="text-muted px-2 py-6 text-center text-sm"
|
|
198
|
+
>
|
|
199
|
+
<slot name="empty">{{ $t('dms_lang.language_add.no_match') }}</slot>
|
|
200
|
+
</p>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
<USelectMenu
|
|
204
|
+
v-else
|
|
205
|
+
:id="props.id"
|
|
206
|
+
v-model="code"
|
|
207
|
+
v-model:search-term="search"
|
|
208
|
+
:items="items"
|
|
209
|
+
value-key="value"
|
|
210
|
+
ignore-filter
|
|
211
|
+
:autofocus="props.autofocus"
|
|
212
|
+
:search-input="{ placeholder: $t('dms_lang.language_add.search') }"
|
|
213
|
+
class="w-full"
|
|
214
|
+
:ui="{ content: 'min-w-80' }"
|
|
215
|
+
>
|
|
216
|
+
<template #leading>
|
|
217
|
+
<LocaleTile v-if="code" :code="code" size="sm" />
|
|
218
|
+
</template>
|
|
219
|
+
<template #default>
|
|
220
|
+
<span v-if="code" class="flex min-w-0 items-center gap-1.5">
|
|
221
|
+
<span class="text-highlighted truncate">{{ fullName(code) }}</span>
|
|
222
|
+
<span class="text-dimmed font-mono text-xs">· {{ code }}</span>
|
|
223
|
+
</span>
|
|
224
|
+
<span v-else class="text-dimmed truncate">{{ props.placeholder }}</span>
|
|
225
|
+
</template>
|
|
226
|
+
<template #item-trailing="{ item }">
|
|
227
|
+
<span class="text-dimmed font-mono text-xs">{{ item.value }}</span>
|
|
228
|
+
</template>
|
|
229
|
+
<template #empty>
|
|
230
|
+
<slot name="empty">{{ $t('dms_lang.language_add.no_match') }}</slot>
|
|
231
|
+
</template>
|
|
232
|
+
</USelectMenu>
|
|
233
|
+
</template>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
type LocaleTileSize = 'sm' | 'md' | 'lg'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
code: string
|
|
6
|
+
size?: LocaleTileSize
|
|
7
|
+
isBase?: boolean
|
|
8
|
+
/**
|
|
9
|
+
* The codes shown next to this one: when one of them shares its language
|
|
10
|
+
* (pt-BR, pt-PT), the tile adds the region to tell them apart.
|
|
11
|
+
*/
|
|
12
|
+
siblings?: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const SIZE_CLASSES: Record<LocaleTileSize, string> = {
|
|
16
|
+
sm: 'h-[18px] min-w-5 rounded-[5px] text-[9px]',
|
|
17
|
+
md: 'h-7 min-w-7 rounded-[7px] text-[10.5px]',
|
|
18
|
+
lg: 'h-10 min-w-10 rounded-[10px] text-[13px]',
|
|
19
|
+
}
|
|
20
|
+
const WIDE_PADDING: Record<LocaleTileSize, string> = {
|
|
21
|
+
sm: 'px-1',
|
|
22
|
+
md: 'px-1.5',
|
|
23
|
+
lg: 'px-2',
|
|
24
|
+
}
|
|
25
|
+
const SHORT_TILE_LENGTH = 3
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
28
|
+
size: 'md',
|
|
29
|
+
isBase: false,
|
|
30
|
+
siblings: () => [],
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const { tileOf } = useLocaleNames()
|
|
34
|
+
|
|
35
|
+
const letters = computed(() => tileOf(props.code, props.siblings))
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<span
|
|
40
|
+
class="inline-grid shrink-0 place-items-center font-mono font-bold tracking-[0.04em]"
|
|
41
|
+
:class="[
|
|
42
|
+
SIZE_CLASSES[props.size],
|
|
43
|
+
letters.length > SHORT_TILE_LENGTH ? WIDE_PADDING[props.size] : '',
|
|
44
|
+
props.isBase
|
|
45
|
+
? 'text-primary bg-(--dms-accent-tint-strong) ring-1 ring-(--dms-accent-line) ring-inset'
|
|
46
|
+
: 'bg-elevated text-toned ring-accented ring-1 ring-inset',
|
|
47
|
+
]"
|
|
48
|
+
aria-hidden="true"
|
|
49
|
+
>
|
|
50
|
+
{{ letters }}
|
|
51
|
+
</span>
|
|
52
|
+
</template>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { scanMessage, type MessagePartKind } from '../../utils/translations'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
text: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface TextPart {
|
|
9
|
+
label: string
|
|
10
|
+
title?: string
|
|
11
|
+
classes?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const CHIP = 'rounded px-1 font-mono text-[0.92em]'
|
|
15
|
+
const PART_CLASSES: Partial<Record<MessagePartKind, string>> = {
|
|
16
|
+
placeholder: `text-secondary bg-secondary/10 ${CHIP}`,
|
|
17
|
+
literal: `text-default bg-(--dms-bg-muted) ${CHIP}`,
|
|
18
|
+
linked: `text-info bg-info/10 ${CHIP}`,
|
|
19
|
+
pipe: `text-dimmed mx-0.5 ${CHIP}`,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const props = defineProps<Props>()
|
|
23
|
+
|
|
24
|
+
const parts = computed<TextPart[]>(() =>
|
|
25
|
+
scanMessage(props.text).parts.map((part) => ({
|
|
26
|
+
label: part.kind === 'literal' ? part.name : part.raw,
|
|
27
|
+
title: part.kind === 'literal' ? part.raw : undefined,
|
|
28
|
+
classes: PART_CLASSES[part.kind],
|
|
29
|
+
})),
|
|
30
|
+
)
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<span class="break-words whitespace-pre-wrap">
|
|
35
|
+
<template v-for="(part, index) in parts" :key="index">
|
|
36
|
+
<span v-if="part.classes" :class="part.classes" :title="part.title">
|
|
37
|
+
{{ part.label }}
|
|
38
|
+
</span>
|
|
39
|
+
<template v-else>{{ part.label }}</template>
|
|
40
|
+
</template>
|
|
41
|
+
</span>
|
|
42
|
+
</template>
|