From 61b8287de0862969ae80f23edff12fb930fa51e2 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 13 May 2025 20:47:03 +0000 Subject: [PATCH] style: format code with Prettier This commit fixes the style issues introduced in 1c9f999 according to the output from Prettier. Details: None --- packages/actions/spec/kbd.spec.js | 354 +++++++++--------- .../actions/spec/navigator.spec.svelte.js | 30 +- packages/actions/spec/utils.spec.js | 6 +- packages/actions/src/kbd.js | 198 +++++----- packages/core/src/mapping.js | 6 +- packages/states/src/proxy.svelte.js | 2 +- 6 files changed, 300 insertions(+), 296 deletions(-) diff --git a/packages/actions/spec/kbd.spec.js b/packages/actions/spec/kbd.spec.js index f3d10199c..9dd76d6a0 100644 --- a/packages/actions/spec/kbd.spec.js +++ b/packages/actions/spec/kbd.spec.js @@ -2,180 +2,180 @@ import { describe, it, expect, beforeEach } from 'vitest' import { getKeyboardAction } from '../src/kbd.js' describe('kbd', () => { - describe('getKeyboardAction', () => { - const options = {} - - beforeEach(() => { - options.orientation = 'horizontal' - options.dir = 'ltr' - options.nested = false - }) - - describe('common behaviors', () => { - it('should return "select" for Enter key press', () => { - const event = new KeyboardEvent('keydown', { key: 'Enter' }) - expect(getKeyboardAction(event, options)).toBe('select') - }) - - it('should return "select" for Space key press', () => { - const event = new KeyboardEvent('keydown', { key: ' ' }) - expect(getKeyboardAction(event, options)).toBe('select') - }) - - it('should return "extend" when Space+Ctrl key is pressed', () => { - const event = new KeyboardEvent('keydown', { key: ' ', ctrlKey: true }) - expect(getKeyboardAction(event, options)).toBe('extend') - }) - - it('should return "extend" when Space+Meta key is pressed', () => { - const event = new KeyboardEvent('keydown', { key: ' ', metaKey: true }) - expect(getKeyboardAction(event, options)).toBe('extend') - }) - - it('should return null if key is not mapped', () => { - const event = new KeyboardEvent('keydown', { key: 'x' }) - expect(getKeyboardAction(event, options)).toBeNull() - }) - }) - - describe('vertical', () => { - beforeEach(() => { - options.orientation = 'vertical' - }) - - describe('ltr', () => { - beforeEach(() => { - options.dir = 'ltr' - }) - - it('should return "previous" for ArrowUp key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) - expect(getKeyboardAction(event, options)).toBe('previous') - }) - - it('should return "next" for ArrowDown key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) - expect(getKeyboardAction(event, options)).toBe('next') - }) - - describe('nested', () => { - beforeEach(() => { - options.nested = true - }) - - it('should return "collapse" for ArrowLeft key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) - expect(getKeyboardAction(event, options)).toBe('collapse') - }) - - it('should return "expand" for ArrowRight key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) - expect(getKeyboardAction(event, options)).toBe('expand') - }) - }) - }) - - describe('rtl', () => { - beforeEach(() => { - options.dir = 'rtl' - }) - - it('should return "previous" for ArrowUp key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) - expect(getKeyboardAction(event, options)).toBe('previous') - }) - - it('should return "next" for ArrowDown key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) - expect(getKeyboardAction(event, options)).toBe('next') - }) - - describe('nested', () => { - beforeEach(() => { - options.nested = true - }) - - it('should return "expand" for ArrowLeft key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) - expect(getKeyboardAction(event, options)).toBe('expand') - }) - - it('should return "collapse" for ArrowRight key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) - expect(getKeyboardAction(event, options)).toBe('collapse') - }) - }) - }) - }) - - describe('horizontal', () => { - beforeEach(() => { - options.orientation = 'horizontal' - }) - - describe('ltr', () => { - beforeEach(() => { - options.dir = 'ltr' - }) - - it('should return "previous" for ArrowLeft key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) - expect(getKeyboardAction(event, options)).toBe('previous') - }) - - it('should return "next" for ArrowRight key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) - expect(getKeyboardAction(event, options)).toBe('next') - }) - - describe('nested', () => { - beforeEach(() => { - options.nested = true - }) - - it('should return "collapse" for ArrowUp key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) - expect(getKeyboardAction(event, options)).toBe('collapse') - }) - - it('should return "expand" for ArrowDown key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) - expect(getKeyboardAction(event, options)).toBe('expand') - }) - }) - }) - - describe('rtl', () => { - beforeEach(() => { - options.dir = 'rtl' - }) - - it('should return "next" for ArrowLeft key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) - expect(getKeyboardAction(event, options)).toBe('next') - }) - - it('should return "previous" for ArrowRight key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) - expect(getKeyboardAction(event, options)).toBe('previous') - }) - - describe('nested', () => { - beforeEach(() => { - options.nested = true - }) - - it('should return "collapse" for ArrowUp key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) - expect(getKeyboardAction(event, options)).toBe('collapse') - }) - - it('should return "expand" for ArrowDown key', () => { - const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) - expect(getKeyboardAction(event, options)).toBe('expand') - }) - }) - }) - }) - }) -}) \ No newline at end of file + describe('getKeyboardAction', () => { + const options = {} + + beforeEach(() => { + options.orientation = 'horizontal' + options.dir = 'ltr' + options.nested = false + }) + + describe('common behaviors', () => { + it('should return "select" for Enter key press', () => { + const event = new KeyboardEvent('keydown', { key: 'Enter' }) + expect(getKeyboardAction(event, options)).toBe('select') + }) + + it('should return "select" for Space key press', () => { + const event = new KeyboardEvent('keydown', { key: ' ' }) + expect(getKeyboardAction(event, options)).toBe('select') + }) + + it('should return "extend" when Space+Ctrl key is pressed', () => { + const event = new KeyboardEvent('keydown', { key: ' ', ctrlKey: true }) + expect(getKeyboardAction(event, options)).toBe('extend') + }) + + it('should return "extend" when Space+Meta key is pressed', () => { + const event = new KeyboardEvent('keydown', { key: ' ', metaKey: true }) + expect(getKeyboardAction(event, options)).toBe('extend') + }) + + it('should return null if key is not mapped', () => { + const event = new KeyboardEvent('keydown', { key: 'x' }) + expect(getKeyboardAction(event, options)).toBeNull() + }) + }) + + describe('vertical', () => { + beforeEach(() => { + options.orientation = 'vertical' + }) + + describe('ltr', () => { + beforeEach(() => { + options.dir = 'ltr' + }) + + it('should return "previous" for ArrowUp key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) + expect(getKeyboardAction(event, options)).toBe('previous') + }) + + it('should return "next" for ArrowDown key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) + expect(getKeyboardAction(event, options)).toBe('next') + }) + + describe('nested', () => { + beforeEach(() => { + options.nested = true + }) + + it('should return "collapse" for ArrowLeft key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) + expect(getKeyboardAction(event, options)).toBe('collapse') + }) + + it('should return "expand" for ArrowRight key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) + expect(getKeyboardAction(event, options)).toBe('expand') + }) + }) + }) + + describe('rtl', () => { + beforeEach(() => { + options.dir = 'rtl' + }) + + it('should return "previous" for ArrowUp key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) + expect(getKeyboardAction(event, options)).toBe('previous') + }) + + it('should return "next" for ArrowDown key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) + expect(getKeyboardAction(event, options)).toBe('next') + }) + + describe('nested', () => { + beforeEach(() => { + options.nested = true + }) + + it('should return "expand" for ArrowLeft key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) + expect(getKeyboardAction(event, options)).toBe('expand') + }) + + it('should return "collapse" for ArrowRight key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) + expect(getKeyboardAction(event, options)).toBe('collapse') + }) + }) + }) + }) + + describe('horizontal', () => { + beforeEach(() => { + options.orientation = 'horizontal' + }) + + describe('ltr', () => { + beforeEach(() => { + options.dir = 'ltr' + }) + + it('should return "previous" for ArrowLeft key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) + expect(getKeyboardAction(event, options)).toBe('previous') + }) + + it('should return "next" for ArrowRight key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) + expect(getKeyboardAction(event, options)).toBe('next') + }) + + describe('nested', () => { + beforeEach(() => { + options.nested = true + }) + + it('should return "collapse" for ArrowUp key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) + expect(getKeyboardAction(event, options)).toBe('collapse') + }) + + it('should return "expand" for ArrowDown key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) + expect(getKeyboardAction(event, options)).toBe('expand') + }) + }) + }) + + describe('rtl', () => { + beforeEach(() => { + options.dir = 'rtl' + }) + + it('should return "next" for ArrowLeft key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowLeft' }) + expect(getKeyboardAction(event, options)).toBe('next') + }) + + it('should return "previous" for ArrowRight key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowRight' }) + expect(getKeyboardAction(event, options)).toBe('previous') + }) + + describe('nested', () => { + beforeEach(() => { + options.nested = true + }) + + it('should return "collapse" for ArrowUp key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowUp' }) + expect(getKeyboardAction(event, options)).toBe('collapse') + }) + + it('should return "expand" for ArrowDown key', () => { + const event = new KeyboardEvent('keydown', { key: 'ArrowDown' }) + expect(getKeyboardAction(event, options)).toBe('expand') + }) + }) + }) + }) + }) +}) diff --git a/packages/actions/spec/navigator.spec.svelte.js b/packages/actions/spec/navigator.spec.svelte.js index f53c62aab..293051e6a 100644 --- a/packages/actions/spec/navigator.spec.svelte.js +++ b/packages/actions/spec/navigator.spec.svelte.js @@ -115,7 +115,9 @@ describe('navigator', () => { }) it('should include expand/collapse when nested in LTR mode', () => { - const cleanup = $effect.root(() => navigator(root, { wrapper, orientation: 'vertical', dir: 'ltr', nested: true })) + const cleanup = $effect.root(() => + navigator(root, { wrapper, orientation: 'vertical', dir: 'ltr', nested: true }) + ) flushSync() root.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowRight' })) expect(wrapper.expand).toHaveBeenCalled() @@ -128,7 +130,9 @@ describe('navigator', () => { describe('vertical RTL', () => { it('should handle vertical navigation keys in RTL mode', () => { - const cleanup = $effect.root(() => navigator(root, { wrapper, orientation: 'vertical', dir: 'rtl' })) + const cleanup = $effect.root(() => + navigator(root, { wrapper, orientation: 'vertical', dir: 'rtl' }) + ) flushSync() // Basic navigation remains the same in RTL (up/down) @@ -146,16 +150,18 @@ describe('navigator', () => { }) it('should flip expand/collapse arrow keys in RTL nested mode', () => { - const cleanup = $effect.root(() => navigator(root, { wrapper, orientation: 'vertical', dir: 'rtl', nested: true })) + const cleanup = $effect.root(() => + navigator(root, { wrapper, orientation: 'vertical', dir: 'rtl', nested: true }) + ) flushSync() - + // In RTL, the meaning of left/right is reversed for tree operations root.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowLeft' })) expect(wrapper.expand).toHaveBeenCalled() root.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowRight' })) expect(wrapper.collapse).toHaveBeenCalled() - + cleanup() }) }) @@ -222,10 +228,12 @@ describe('navigator', () => { cleanup() }) }) - + describe('horizontal RTL', () => { it('should reverse left/right navigation keys in horizontal RTL mode', () => { - const cleanup = $effect.root(() => navigator(root, { wrapper, orientation: 'horizontal', dir: 'rtl' })) + const cleanup = $effect.root(() => + navigator(root, { wrapper, orientation: 'horizontal', dir: 'rtl' }) + ) flushSync() // In RTL horizontal mode, left/right arrow keys are reversed @@ -241,20 +249,20 @@ describe('navigator', () => { cleanup() }) - + it('should retain expand/collapse keys in horizontal RTL nested mode', () => { - const cleanup = $effect.root(() => + const cleanup = $effect.root(() => navigator(root, { wrapper, orientation: 'horizontal', dir: 'rtl', nested: true }) ) flushSync() - + // In horizontal mode, up/down for expand/collapse is not affected by RTL root.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowDown' })) expect(wrapper.expand).toHaveBeenCalled() root.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowUp' })) expect(wrapper.collapse).toHaveBeenCalled() - + cleanup() }) }) diff --git a/packages/actions/spec/utils.spec.js b/packages/actions/spec/utils.spec.js index f8b6774e6..4d05b2b19 100644 --- a/packages/actions/spec/utils.spec.js +++ b/packages/actions/spec/utils.spec.js @@ -1,9 +1,5 @@ import { describe, it, expect, beforeEach } from 'vitest' -import { - getClosestAncestorWithAttribute, - getEventForKey, - getClickAction -} from '../src/utils.js' +import { getClosestAncestorWithAttribute, getEventForKey, getClickAction } from '../src/utils.js' describe('utils', () => { describe('getClosestAncestorWithAttribute', () => { diff --git a/packages/actions/src/kbd.js b/packages/actions/src/kbd.js index fa7c8b3ca..58b5e10d1 100644 --- a/packages/actions/src/kbd.js +++ b/packages/actions/src/kbd.js @@ -5,9 +5,9 @@ * @returns {Object} Object mapping arrow keys to movement handlers */ function getHorizontalMovementActions(handlers, dir = 'ltr') { - return dir === 'rtl' - ? { ArrowRight: handlers.previous, ArrowLeft: handlers.next } - : { ArrowLeft: handlers.previous, ArrowRight: handlers.next } + return dir === 'rtl' + ? { ArrowRight: handlers.previous, ArrowLeft: handlers.next } + : { ArrowLeft: handlers.previous, ArrowRight: handlers.next } } /** @@ -16,7 +16,7 @@ function getHorizontalMovementActions(handlers, dir = 'ltr') { * @returns {Object} Object mapping arrow keys to movement handlers */ function getVerticalMovementActions(handlers) { - return { ArrowUp: handlers.previous, ArrowDown: handlers.next } + return { ArrowUp: handlers.previous, ArrowDown: handlers.next } } /** @@ -25,7 +25,7 @@ function getVerticalMovementActions(handlers) { * @returns {Object} Object mapping arrow keys to expand/collapse handlers */ function getHorizontalExpandActions(handlers) { - return { ArrowUp: handlers.collapse, ArrowDown: handlers.expand } + return { ArrowUp: handlers.collapse, ArrowDown: handlers.expand } } /** @@ -35,9 +35,9 @@ function getHorizontalExpandActions(handlers) { * @returns {Object} Object mapping arrow keys to expand/collapse handlers */ function getVerticalExpandActions(handlers, dir = 'ltr') { - return dir === 'rtl' - ? { ArrowRight: handlers.collapse, ArrowLeft: handlers.expand } - : { ArrowLeft: handlers.collapse, ArrowRight: handlers.expand } + return dir === 'rtl' + ? { ArrowRight: handlers.collapse, ArrowLeft: handlers.expand } + : { ArrowLeft: handlers.collapse, ArrowRight: handlers.expand } } /** @@ -46,18 +46,18 @@ function getVerticalExpandActions(handlers, dir = 'ltr') { * @returns {Object} Object mapping keys to selection handlers */ function getCommonActions(handlers) { - return { - Enter: handlers.select, - ' ': handlers.select - } + return { + Enter: handlers.select, + ' ': handlers.select + } } // Default navigation options export const defaultNavigationOptions = { - orientation: 'vertical', - dir: 'ltr', - nested: false, - enabled: true + orientation: 'vertical', + dir: 'ltr', + nested: false, + enabled: true } /** @@ -67,29 +67,29 @@ export const defaultNavigationOptions = { * @returns {Object} Object mapping key presses to handler functions */ export function getKeyboardActions(options, handlers) { - const { orientation, dir, nested, enabled } = { ...defaultNavigationOptions, ...options } - - if (!enabled) return {} - - const common = getCommonActions(handlers) - - // Determine movement actions based on orientation - const isHorizontal = orientation === 'horizontal' - const movement = isHorizontal - ? getHorizontalMovementActions(handlers, dir) - : getVerticalMovementActions(handlers) - - // If not nested, we don't need expand/collapse actions - if (!nested) { - return { ...common, ...movement } - } - - // Determine expand/collapse actions based on orientation - const expandCollapse = isHorizontal - ? getHorizontalExpandActions(handlers) - : getVerticalExpandActions(handlers, dir) - - return { ...common, ...movement, ...expandCollapse } + const { orientation, dir, nested, enabled } = { ...defaultNavigationOptions, ...options } + + if (!enabled) return {} + + const common = getCommonActions(handlers) + + // Determine movement actions based on orientation + const isHorizontal = orientation === 'horizontal' + const movement = isHorizontal + ? getHorizontalMovementActions(handlers, dir) + : getVerticalMovementActions(handlers) + + // If not nested, we don't need expand/collapse actions + if (!nested) { + return { ...common, ...movement } + } + + // Determine expand/collapse actions based on orientation + const expandCollapse = isHorizontal + ? getHorizontalExpandActions(handlers) + : getVerticalExpandActions(handlers, dir) + + return { ...common, ...movement, ...expandCollapse } } /** @@ -97,50 +97,52 @@ export function getKeyboardActions(options, handlers) { * * @param {Object} options - Navigation options * @param {string} options.orientation - Whether navigation is horizontal or vertical - * @param {string} options.dir - Text direction ('ltr' or 'rtl') + * @param {string} options.dir - Text direction ('ltr' or 'rtl') * @param {boolean} options.nested - Whether navigation is nested * @returns {Object} Mapping of keys to actions */ export function createKeyboardActionMap(options) { - const { orientation, dir, nested } = options - const isHorizontal = orientation === 'horizontal' - - // Define movement actions based on orientation and direction - let movementActions = {} - if (isHorizontal) { - movementActions = dir === 'rtl' - ? { ArrowRight: 'previous', ArrowLeft: 'next' } - : { ArrowLeft: 'previous', ArrowRight: 'next' } - } else { - movementActions = { ArrowUp: 'previous', ArrowDown: 'next' } - } - - // Define expand/collapse actions for nested option - let nestedActions = {} - if (nested) { - if (isHorizontal) { - nestedActions = { ArrowUp: 'collapse', ArrowDown: 'expand' } - } else { - nestedActions = dir === 'rtl' - ? { ArrowRight: 'collapse', ArrowLeft: 'expand' } - : { ArrowLeft: 'collapse', ArrowRight: 'expand' } - } - } - - // Common actions regardless of options - const commonActions = { - Enter: 'select', - ' ': 'select', - Home: 'first', - End: 'last' - } - - // Combine all possible actions - return { - ...commonActions, - ...movementActions, - ...nestedActions - } + const { orientation, dir, nested } = options + const isHorizontal = orientation === 'horizontal' + + // Define movement actions based on orientation and direction + let movementActions = {} + if (isHorizontal) { + movementActions = + dir === 'rtl' + ? { ArrowRight: 'previous', ArrowLeft: 'next' } + : { ArrowLeft: 'previous', ArrowRight: 'next' } + } else { + movementActions = { ArrowUp: 'previous', ArrowDown: 'next' } + } + + // Define expand/collapse actions for nested option + let nestedActions = {} + if (nested) { + if (isHorizontal) { + nestedActions = { ArrowUp: 'collapse', ArrowDown: 'expand' } + } else { + nestedActions = + dir === 'rtl' + ? { ArrowRight: 'collapse', ArrowLeft: 'expand' } + : { ArrowLeft: 'collapse', ArrowRight: 'expand' } + } + } + + // Common actions regardless of options + const commonActions = { + Enter: 'select', + ' ': 'select', + Home: 'first', + End: 'last' + } + + // Combine all possible actions + return { + ...commonActions, + ...movementActions, + ...nestedActions + } } /** @@ -151,12 +153,12 @@ export function createKeyboardActionMap(options) { * @returns {Object} Mapping of keys to actions */ export function createModifierKeyboardActionMap(options) { - const isHorizontal = options.orientation === 'horizontal' - const common = { ' ': 'extend', Home: 'first', End: 'last' } - const directional = isHorizontal - ? { ArrowLeft: 'first', ArrowRight: 'last' } - : { ArrowUp: 'first', ArrowDown: 'last' } - return { ...common, ...directional } + const isHorizontal = options.orientation === 'horizontal' + const common = { ' ': 'extend', Home: 'first', End: 'last' } + const directional = isHorizontal + ? { ArrowLeft: 'first', ArrowRight: 'last' } + : { ArrowUp: 'first', ArrowDown: 'last' } + return { ...common, ...directional } } /** @@ -166,20 +168,20 @@ export function createModifierKeyboardActionMap(options) { * @returns {string|null} The action to perform, or null if no action is defined */ export function getKeyboardAction(event, options = {}) { - const { key, ctrlKey, metaKey } = event + const { key, ctrlKey, metaKey } = event - // Use updated options with defaults - const mergedOptions = { ...defaultNavigationOptions, ...options } + // Use updated options with defaults + const mergedOptions = { ...defaultNavigationOptions, ...options } - // Check for modifier keys first (highest priority) - if (ctrlKey || metaKey) { - const modifierMap = createModifierKeyboardActionMap(mergedOptions) - return modifierMap[key] || null - } + // Check for modifier keys first (highest priority) + if (ctrlKey || metaKey) { + const modifierMap = createModifierKeyboardActionMap(mergedOptions) + return modifierMap[key] || null + } - // Get the action map based on options - const actionMap = createKeyboardActionMap(mergedOptions) + // Get the action map based on options + const actionMap = createKeyboardActionMap(mergedOptions) - // Return the action or null if no matching key - return actionMap[key] || null -} \ No newline at end of file + // Return the action or null if no matching key + return actionMap[key] || null +} diff --git a/packages/core/src/mapping.js b/packages/core/src/mapping.js index 254dc5604..6fc3a0013 100644 --- a/packages/core/src/mapping.js +++ b/packages/core/src/mapping.js @@ -11,7 +11,7 @@ import { has } from 'ramda' */ export function getComponent(value, fields, using) { return fields.component && isObject(value) - ? (using[value[fields.component]] ?? using.default) + ? using[value[fields.component]] ?? using.default : using.default } @@ -51,9 +51,7 @@ export function getIcon(value, fields = defaultFields) { * @returns {*} */ export function getValue(node, fields = defaultFields) { - return typeof node === 'object' && node !== null - ? (node[fields.value] ?? node[fields.text]) - : node + return typeof node === 'object' && node !== null ? node[fields.value] ?? node[fields.text] : node } /** diff --git a/packages/states/src/proxy.svelte.js b/packages/states/src/proxy.svelte.js index a1cd2f5db..6bf6d1550 100644 --- a/packages/states/src/proxy.svelte.js +++ b/packages/states/src/proxy.svelte.js @@ -13,7 +13,7 @@ export class Proxy { this.fields = fields this.#original = value this.#value = typeof value === 'object' ? value : { [this.fields.text]: value } - this.id = typeof value === 'object' ? (this.get('id') ?? id()) : value + this.id = typeof value === 'object' ? this.get('id') ?? id() : value } #processChildren() {