From a7d17821fc6016771297aed1b8bbe51053049725 Mon Sep 17 00:00:00 2001 From: Michael Moore Date: Sun, 28 Apr 2024 12:29:35 -0500 Subject: [PATCH] feat(ui): make the app translatable --- .vscode/settings.json | 1 + electron.vite.config.ts | 2 +- package-lock.json | 60 ++- package.json | 3 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- src/renderer/src/App.svelte | 3 +- src/renderer/src/intl/en-US.ts | 332 +++++++++++++++++ src/renderer/src/intl/index.ts | 63 ++++ .../src/lib/ApplyChangesButton.svelte | 3 +- .../lib/ColorSettingAdjustmentControl.svelte | 15 +- .../src/lib/ColorSettingControl.svelte | 17 +- src/renderer/src/lib/ExportModal.svelte | 30 +- .../src/lib/IconSettingControl.svelte | 25 +- src/renderer/src/lib/MapSettingControl.svelte | 23 +- src/renderer/src/lib/Sidebar.svelte | 49 +-- .../src/lib/StrokeSettingControl.svelte | 21 +- src/renderer/src/lib/VersionInfo.svelte | 6 +- src/renderer/src/lib/constants.ts | 2 +- src/renderer/src/lib/map/MapContainer.svelte | 18 +- src/renderer/src/lib/map/MapTooltip.svelte | 5 +- src/renderer/src/lib/mapSettings.ts | 352 ++++++++---------- 23 files changed, 738 insertions(+), 298 deletions(-) create mode 100644 src/renderer/src/intl/en-US.ts create mode 100644 src/renderer/src/intl/index.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 63b457b..022f9a0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,6 +11,7 @@ "skeletonlabs", "Starbase", "starbases", + "starscape", "steamapps", "stellaris", "stellarmaps", diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 79b3c0b..d21d29a 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig, externalizeDepsPlugin } from 'electron-vite'; import { svelte } from '@sveltejs/vite-plugin-svelte'; +import { defineConfig, externalizeDepsPlugin } from 'electron-vite'; export default defineConfig({ main: { diff --git a/package-lock.json b/package-lock.json index f718b5b..bb66506 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "stellarmaps", - "version": "0.10.2", + "version": "0.11.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "stellarmaps", - "version": "0.10.2", + "version": "0.11.0-dev", "dependencies": { "@electron-toolkit/preload": "^3.0.1", "@electron-toolkit/utils": "^3.0.0", @@ -26,6 +26,7 @@ "electron": "^29.3.0", "fast-glob": "^3.3.2", "font-list": "^1.5.1", + "intl-messageformat": "^10.5.11", "magickwand.js": "^1.0.2", "pixi.js": "^8.1.0", "platform-paths": "^1.2.2", @@ -1574,6 +1575,50 @@ "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.1.tgz", "integrity": "sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==" }, + "node_modules/@formatjs/ecma402-abstract": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.18.2.tgz", + "integrity": "sha512-+QoPW4csYALsQIl8GbN14igZzDbuwzcpWrku9nyMXlaqAlwRBgl5V+p0vWMGFqHOw37czNXaP/lEk4wbLgcmtA==", + "dependencies": { + "@formatjs/intl-localematcher": "0.5.4", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/fast-memoize": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-2.2.0.tgz", + "integrity": "sha512-hnk/nY8FyrL5YxwP9e4r9dqeM6cAbo8PeU9UjyXojZMNvVad2Z06FAVHyR3Ecw6fza+0GH7vdJgiKIVXTMbSBA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/icu-messageformat-parser": { + "version": "2.7.6", + "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.7.6.tgz", + "integrity": "sha512-etVau26po9+eewJKYoiBKP6743I1br0/Ie00Pb/S/PtmYfmjTcOn2YCh2yNkSZI12h6Rg+BOgQYborXk46BvkA==", + "dependencies": { + "@formatjs/ecma402-abstract": "1.18.2", + "@formatjs/icu-skeleton-parser": "1.8.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/icu-skeleton-parser": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.8.0.tgz", + "integrity": "sha512-QWLAYvM0n8hv7Nq5BEs4LKIjevpVpbGLAJgOaYzg9wABEoX1j0JO1q2/jVkO6CVlq0dbsxZCngS5aXbysYueqA==", + "dependencies": { + "@formatjs/ecma402-abstract": "1.18.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/intl-localematcher": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz", + "integrity": "sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -7399,6 +7444,17 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/intl-messageformat": { + "version": "10.5.11", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-10.5.11.tgz", + "integrity": "sha512-eYq5fkFBVxc7GIFDzpFQkDOZgNayNTQn4Oufe8jw6YY6OHVw70/4pA3FyCsQ0Gb2DnvEJEMmN2tOaXUGByM+kg==", + "dependencies": { + "@formatjs/ecma402-abstract": "1.18.2", + "@formatjs/fast-memoize": "2.2.0", + "@formatjs/icu-messageformat-parser": "2.7.6", + "tslib": "^2.4.0" + } + }, "node_modules/is-arguments": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", diff --git a/package.json b/package.json index 21bf523..ac28b21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stellarmaps", - "version": "0.10.3", + "version": "0.11.0-dev", "private": true, "type": "module", "scripts": { @@ -85,6 +85,7 @@ "electron": "^29.3.0", "fast-glob": "^3.3.2", "font-list": "^1.5.1", + "intl-messageformat": "^10.5.11", "magickwand.js": "^1.0.2", "pixi.js": "^8.1.0", "platform-paths": "^1.2.2", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 83e7970..6910ee2 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "stellarmaps" -version = "0.10.2" +version = "0.10.3" dependencies = [ "anyhow", "assert-json-diff", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a7a34bd..f7752be 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stellarmaps" -version = "0.10.3" +version = "0.11.0-dev" description = "Stellaris map renderer" authors = ["Michael Moore"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a7ca79d..e4d50d7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "StellarMaps", - "version": "0.10.3" + "version": "0.11.0-dev" }, "tauri": { "allowlist": { diff --git a/src/renderer/src/App.svelte b/src/renderer/src/App.svelte index c5374fe..d2d91e4 100644 --- a/src/renderer/src/App.svelte +++ b/src/renderer/src/App.svelte @@ -9,6 +9,7 @@ storePopup, } from '@skeletonlabs/skeleton'; import './app.postcss'; + import { t } from './intl'; import ExportModal from './lib/ExportModal.svelte'; import Sidebar from './lib/Sidebar.svelte'; import VersionInfo from './lib/VersionInfo.svelte'; @@ -25,7 +26,7 @@ - StellarMaps + {$t('top_bar.stellar_maps')} diff --git a/src/renderer/src/intl/en-US.ts b/src/renderer/src/intl/en-US.ts new file mode 100644 index 0000000..769b6ee --- /dev/null +++ b/src/renderer/src/intl/en-US.ts @@ -0,0 +1,332 @@ +export default { + // messages in the top bar of the app + top_bar: { + stellar_maps: 'StellarMaps', + download_latest_release: 'Download Latest Release', + }, + // messages in the side bar (save selection and map settings) + // note: messages for specific settings are in the 'setting' and 'option' sections + side_bar: { + save_game: 'Save Game', // header above controls to select save + refresh_saves_button: 'Refresh', + select_manually_button: 'Select Manually', + select_save_placeholder: 'Select a save...', + load_save_button: 'Load Save', + map_settings: 'Map Settings', + save_settings_button: 'Save', + load_settings_button: 'Load', + custom_setting_profiles: 'Custom', + preset_setting_profiles: 'Preset', + apply_changes_button: 'Apply Changes', + }, + // messages in the main map section + map: { + select_save: 'Select a save in the top left', + loading: 'This could take a few seconds', + error: 'Something has gone wrong', + }, + // various generic messages + generic: { + enabled: 'Enabled', + disabled: 'Disabled', + cancel_button: 'Cancel', + loading: 'Loading...', + confirmation: 'Are you sure?', + }, + // various confirmation popups + confirmation: { + unsaved_setting_profile: + 'You have customized map settings that have not been saved. These changes will be lost.', + delete_setting_profile: 'You are about to delete "{name}". This cannot be undone.', + }, + // various prompt popups + prompt: { + enter_settings_profile_name: 'Enter a name', + select_save_file: 'Select Save', + select_save_file_filter_name: 'Stellaris Save', + select_stellaris_install: 'Select Stellaris Install Folder', + }, + // input validation messages + validation: { + required: 'Required', + min: 'Min: {min, number}', + max: 'Max: {max, number}', + min_max: 'Min: {min, number}, Max: {max, number}', + }, + // various notification popups + notification: { + settings_profile_saved: '"{name}" settings saved', + failed_to_load_save_list: 'Failed to load Stellaris saves', + failed_to_load_save_file: 'Failed to load {filePath}', + export_success: 'Export Successful', + export_failed: 'Export Failed', + failed_to_load_stellaris_data: { + title: 'Failed to load Stellaris data', + description: + 'Please try manually selecting your install location. This should be the folder that contains the "common", "flags", and "localisation" folders (among others).', + action: 'Select Install', + }, + }, + // messages for the export button and popup + export: { + button: 'Export', + header: 'Export Image', + image_size: 'Image Size', + lock_aspect_ratio: 'Lock Aspect Ratio', + zoom: 'Zoom', + center: 'Center', + center_hint: '(The galaxy is about 1000 units across.)', + preview: 'Preview:', + click_to_center: '(Click to center)', + reset_button: 'Reset', + export_svg_button: 'Export SVG', + export_png_button: 'Export PNG', + processing: 'Processing...', + }, + // labels for various types of setting controls + // (shared by multiple settings) + control: { + color: { + label: 'Color', + adjustment: { + header: 'Color Adjustments', + add_button: '+ Add Adjustment', + placeholder: 'Select type...', + }, + }, + icon: { + label: 'Icon', + size: 'Size', + advanced_options: { + header: 'Advanced Options', + position: 'Position', + priority: 'Priority', + }, + }, + stroke: { + width: 'Width', + more_styles: { + header: 'More Styles', + smoothed: 'Smoothed', + glow: 'Glow', + dashed: 'Dashed', + dash_pattern: 'Dash Pattern', + }, + }, + }, + // dropdown options for various settings + option: { + color: { + group: { + dynamic: 'Dynamic Colors', + stellaris: 'Stellaris Colors', + stellar_maps: 'StellarMaps Colors', + }, + primary: 'Primary', + secondary: 'Secondary', + border: 'Border', + }, + color_adjustment: { + LIGHTEN: 'Lighten', + DARKEN: 'Darken', + MIN_LIGHTNESS: 'Min Lightness', + MAX_LIGHTNESS: 'Max Lightness', + MIN_CONTRAST: 'Min Contrast', + OPACITY: 'Opacity', + }, + icon: { + group: { + basic_shape: 'Basic Shapes', + stars: 'Stars', + other_shapes: 'Other Shapes', + stellaris: 'Stellaris', + }, + triangle: 'Triangle', + triangle_flat: 'Triangle (flat top)', + diamond: 'Diamond', + square: 'Square', + pentagon: 'Pentagon', + pentagon_flat: 'Pentagon (flat top)', + hexagon: 'Hexagon', + hexagon_flat: 'Hexagon (flat top)', + heptagon: 'Heptagon', + heptagon_flat: 'Heptagon (flat top)', + octagon: 'Octagon', + octagon_flat: 'Octagon (flat top)', + circle: 'Circle', + star_3_pointed: '3-Pointed Star', + star_4_pointed: '4-Pointed Star', + star_5_pointed: '5-Pointed Star', + star_6_pointed: '6-Pointed Star', + star_7_pointed: '7-Pointed Star', + star_8_pointed: '8-Pointed Star', + cross: 'Cross', + wormhole: 'Wormhole', + gateway: 'Gateway', + l_gate: 'L-Gate', + shroud_tunnel: 'Shroud Tunnel (unofficial)', + }, + icon_position: { + center: 'Center', + left: 'Left', + right: 'Right', + top: 'Top', + bottom: 'Bottom', + }, + glyph: { + none: 'None', + star_4_pointed: '✦ 4-Pointed Star', + star_4_pointed_outline: '✧ 4-Pointed Star (outline)', + star_5_pointed: '★ 5-Pointed Star', + star_5_pointed_outline: '☆ 5-Pointed Star (outline)', + star_5_pointed_circled: '✪ 5-Pointed Star (circled)', + star_5_pointed_pinwheel: '✯ 5-Pointed Star (pinwheel)', + star_6_pointed: '✶ 6-Pointed Star', + star_8_pointed: '✴ 8-Pointed Star', + }, + union: { + joined_borders: 'Same Color, Joined Borders', + separate_borders: 'Same Color, Separate Borders', + off: 'Off', + }, + union_federations_color: { + founder: 'Founder', + leader: 'Current Leader', + }, + country_names_type: { + country_only: 'Country Name Only', + player_only: 'Player Name Only', + country_then_player: 'Country then Player Name', + player_then_country: 'Player then Country Name', + }, + labels_avoid_holes: { + all: 'All', + owned: 'Owned', + none: 'None', + }, + terra_incognita_perspective_country: { + player: 'Player', + }, + terra_incognita_style: { + flat: 'Flat', + striped: 'Striped', + cloudy: 'Cloudy', + }, + }, + // labels and tooltips for various settings + setting: { + group: { + borders: 'Borders', + unions: 'Union Mode', + countryLabels: 'Country Labels', + systemIcons: 'System Icons', + hyperlanes: 'Hyperlanes', + bypassLinks: 'Bypass Links', + terraIncognita: 'Terra Incognita', + misc: 'Miscellaneous', + advancedBorder: 'Advanced Border Settings', + starscape: 'Starscape', + }, + borderStroke: 'Country Borders', + borderColor: 'Country Border Color', + borderFillColor: 'Country Fill Color', + borderFillFade: 'Country Fill Fade', + sectorBorderStroke: 'Sector Borders', + sectorBorderColor: 'Sector Border Color', + unionBorderStroke: 'Union Borders', + unionMode: 'Union Mode', + unionSubjects: 'Subjects', + unionFederations: 'Federations', + unionFederationsColor: 'Federation Member Color', + unionLeaderSymbol: 'Union Leader Symbol', + unionLeaderSymbolSize: 'Union Leader Symbol Size', + unionLeaderUnderline: 'Underline Union Leader Name', + countryNames: 'Names', + countryNamesType: 'Name Type', + countryNamesMinSize: 'Name Min Size', + countryNamesMaxSize: 'Name Max Size', + countryNamesSecondaryRelativeSize: 'Secondary Name Relative Size', + countryNamesFont: 'Font', + countryEmblems: 'Emblems', + countryEmblemsMinSize: 'Emblem Min Size', + countryEmblemsMaxSize: 'Emblem Max Size', + labelsAvoidHoles: 'Avoid Holes in Border', + countryCapitalIcon: 'Country Capital', + sectorCapitalIcon: 'Sector Capital', + populatedSystemIcon: 'Populated System', + unpopulatedSystemIcon: 'Other System', + wormholeIcon: 'Wormhole', + gatewayIcon: 'Gateway', + lGateIcon: 'L-Gate', + shroudTunnelIcon: 'Shroud Tunnel', + hyperlaneStroke: 'Hyperlanes', + hyperlaneColor: 'Hyperlane Color', + unownedHyperlaneColor: 'Unowned Hyperlane Color', + hyperRelayStroke: 'Hyper Relays', + hyperRelayColor: 'Hyper Relay Color', + unownedHyperRelayColor: 'Unowned Hyper Relay Color', + hyperlaneMetroStyle: 'Metro-style Hyperlanes', + hyperlaneMetroStyle_tooltip: `
    +
  • Draw hyperlanes in the style of metro/subway maps.
  • +
  • Automatically enables "Align Solar Systems to Grid".
  • +
`, + wormholeStroke: 'Wormhole Links', + wormholeStrokeColor: 'Wormhole Links Color', + lGateStroke: 'L-Gate Links', + lGateStrokeColor: 'L-Gate Links Color', + shroudTunnelStroke: 'Shroud Tunnel Links', + shroudTunnelStrokeColor: 'Shroud Tunnel Links Color', + terraIncognita: 'Terra Incognita', + terraIncognitaPerspectiveCountry: 'Perspective Country', + terraIncognitaStyle: 'Style', + terraIncognitaBrightness: 'Brightness', + backgroundColor: 'Background Color', + alignStarsToGrid: 'Align Solar Systems to Grid', + circularGalaxyBorders: 'Circular Galaxy Borders', + circularGalaxyBorders_tooltip: `
    +
  • When enabled, the overall border of the galaxy will be circular in shape, and there will be no "holes" between systems.
  • +
  • If the galaxy is a "Starburst", a special spiral shape will be used instead of a circle.
  • +
`, + hyperlaneSensitiveBorders: 'Hyperlane Sensitive Borders', + hyperlaneSensitiveBorders_tooltip: `
    +
  • When enabled, borders will follow hyperlanes.
  • +
  • When disabled, only solar systems affect borders.
  • +
  • Not supported if the following are enabled:
  • +
    • +
    • Metro-style Hyperlanes
    • +
    • Align Solar Systems to Grid
    • +
  • +
`, + voronoiGridSize: 'Voronoi Grid Size', + voronoiGridSize_tooltip: `
    +
  • Higher values make borders "looser".
  • +
  • Lower values make borders "tighter".
  • +
  • Lower values take longer to process.
  • +
  • WARNING: values below 10 can take a very long time to process.
  • +
`, + claimVoidMaxSize: 'Claim Bordering Void Max Size', + claimVoidMaxSize_tooltip: `
    +
  • Empty "void" between systems can be claimed by neighboring country borders.
  • +
  • Only void smaller than this size can be claimed.
  • +
  • Set to 0 or leave empty to disable this behavior entirely.
  • +
`, + claimVoidBorderThreshold: 'Claim Bordering Void Threshold', + claimVoidBorderThreshold_tooltip: `
    +
  • Empty pockets of "void" between systems can be claimed by neighboring country borders.
  • +
  • To claim void, a country much control at least this much of the void's border.
  • +
  • Set to full so only fully enclosed void is claimed.
  • +
  • Set to empty so all void bordering at least one country is claimed.
  • +
`, + starScapeDust: 'Dust', + starScapeDustColor: 'Dust Color', + starScapeNebula: 'Nebulas', + starScapeNebulaColor: 'Nebula Color', + starScapeNebulaAccentColor: 'Nebula Accent Color', + starScapeCore: 'Core', + starScapeCoreColor: 'Core Color', + starScapeCoreAccentColor: 'Core Accent Color', + starScapeStars: 'Stars', + starScapeStarsColor: 'Stars Color', + starScapeStarsCount: 'Star Count', + }, +}; diff --git a/src/renderer/src/intl/index.ts b/src/renderer/src/intl/index.ts new file mode 100644 index 0000000..4ff0565 --- /dev/null +++ b/src/renderer/src/intl/index.ts @@ -0,0 +1,63 @@ +import IntlMessageFormat, { type FormatXMLElementFn, type PrimitiveType } from 'intl-messageformat'; +import { derived, writable } from 'svelte/store'; +import enUS from './en-US'; + +type Paths = T extends object + ? { + [K in keyof T]: `${Exclude}${Paths extends never ? '' : `.${Paths}`}`; + }[keyof T] + : never; + +export type MessageID = Paths; + +type UnflattenedMessages = { [key: string]: string | UnflattenedMessages }; +function flattenMessages(messages: UnflattenedMessages, prefix = ''): Record { + return Object.fromEntries( + Object.entries(messages).flatMap(([k, v]) => + typeof v === 'string' + ? [[`${prefix}${k}`, v]] + : Object.entries(flattenMessages(v, `${prefix}${k}.`)), + ), + ); +} + +const locales = { + 'en-US': flattenMessages(enUS) as Record, + placeholder: flattenMessages(enUS) as Partial>, +}; +type Locale = keyof typeof locales; + +console.warn(locales); + +function getBestLocale(): Locale { + const keys = Object.keys(locales) as [Locale, ...Locale[]]; + return ( + // exact match + keys.find((key) => key === navigator.language) ?? + // otherwise first matching language + keys.find((key) => key.startsWith(`${navigator.language.split('-')[0]}-`)) ?? + // otherwise first (en-US) + keys[0] + ); +} + +const locale = writable(getBestLocale()); + +export const t = derived(locale, (localeKey) => { + const messages: Record = {}; + return function t( + messageId: MessageID, + values?: Record>, + ) { + const message = + messages[messageId] ?? + new IntlMessageFormat( + locales[localeKey][messageId] ?? locales['en-US'][messageId], + localeKey, + ); + if (values) { + console.warn(message.format(values)); + } + return `${message.format(values)}`; + }; +}); diff --git a/src/renderer/src/lib/ApplyChangesButton.svelte b/src/renderer/src/lib/ApplyChangesButton.svelte index d0f479e..4214165 100644 --- a/src/renderer/src/lib/ApplyChangesButton.svelte +++ b/src/renderer/src/lib/ApplyChangesButton.svelte @@ -1,4 +1,5 @@
import { Accordion, AccordionItem } from '@skeletonlabs/skeleton'; + import { t } from '../intl'; import ColorSettingAdjustmentControl from './ColorSettingAdjustmentControl.svelte'; import { colorDynamicOptions, @@ -21,14 +22,15 @@ .filter(isDefined) .filter( // don't show dynamic colors group if no dynamic colors are allowed - (group) => !(group === 'Dynamic Colors' && config.allowedDynamicColors?.length === 0), + (group) => + !(group === 'option.color.group.dynamic' && config.allowedDynamicColors?.length === 0), ), ), ); $: selectValue = options.find((option) => option.id === value.color)?.id; function filterAllowedOption(option: SelectOption) { - if (option.group !== 'Dynamic Colors') return true; + if (option.group !== 'option.color.group.dynamic') return true; if (config.allowedDynamicColors == null) return true; return (config.allowedDynamicColors as string[]).includes(option.id); } @@ -37,7 +39,7 @@