Files
AtreidesAssetsFree/client/ui/shared-setup.js
T

61 lines
2.3 KiB
JavaScript
Raw Normal View History

2026-10-29 11:57:29 +01:00
// Generated, do not edit. sha256:b9399a3f08d3b6cb92193bf072e6f03992ddd419185b08d9e50b633d21567d88
import { configureDialog } from './dialog.js';
import { configureTabs } from './tabs.js';
import { configureFilter } from './filter.js';
import { configureLoading } from './loading.js';
import { configureTable } from './table.js';
import { openUnitConvert } from './unit-convert.js';
import { hasSubunit } from './format.js';
import { SWAP } from './icons.js';
import { appSetting } from '../app-settings.js';
import { renderErrorPanel } from './error-panel.js';
import { isBlurred, unblur } from './blur.js';
import { CLOSE, EYE_OFF } from './icons.js';
import { t } from '../i18n/index.js';
export function mountBlurEye(d, done) {
const title = d.querySelector('.dialog-title');
if (!title) return;
const sync = e => {
const on = e?.detail ? e.detail.on : isBlurred();
const eye = title.querySelector('.dialog-eye');
if (!on) { eye?.remove(); return; }
if (eye) return;
const b = document.createElement('button');
b.type = 'button';
b.className = 'dialog-eye';
b.title = t('blur.showAmounts');
b.setAttribute('aria-label', t('blur.showAmounts'));
b.innerHTML = EYE_OFF;
b.addEventListener('click', () => unblur());
title.appendChild(b);
};
sync();
document.addEventListener('blur-changed', sync);
done.finally(() => document.removeEventListener('blur-changed', sync));
}
export function configureSharedUi() {
configureDialog({
labels: {
ok: t('dialog.ok'), cancel: t('dialog.cancel'), close: t('dialog.close'), next: t('dialog.next'),
back: t('dialog.back'), finish: t('dialog.finish'), skip: t('dialog.skip'),
},
closeIcon: CLOSE,
onDetail: mountBlurEye,
});
configureTabs({ onError: renderErrorPanel });
configureFilter({ labels: { all: t('filter.all'), none: t('filter.none') } });
configureLoading({ labels: { loading: t('common.loading'), loadError: t('common.loadError') } });
configureTable({
labels: {
new: t('table.new'), save: t('table.save'), cancel: t('table.cancel'), none: t('table.none'),
search: t('table.search'), count: t('table.count'), edit: t('table.edit'),
},
convert: { canConvert: hasSubunit, open: openUnitConvert, icon: SWAP },
repeatKey: () => appSetting('repeat_entry_key'),
});
}
configureSharedUi();