@picked/svelte 0.0.62-next.7 → 0.0.62-next.9

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.
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  /** @file Editable table row for a single field response in the devtools responses screen. */
3
- import type { ResponseListItem, PrimitiveFieldValue, Field } from '@picked/client'
3
+ import type { ResponseListItem, Field, FieldValue, JsonValue } from '@picked/client'
4
4
  import { getPicked } from '../../../../hooks'
5
5
  import { Button, Text, CodeBlock, Banner, Stack } from '../../ui'
6
6
 
@@ -13,7 +13,7 @@
13
13
  let editValue = ''
14
14
  let editError = ''
15
15
  // eslint-disable-next-line svelte/prefer-svelte-reactivity -- Set is reassigned for Svelte reactivity via `selectedOptions = selectedOptions`
16
- let selectedOptions: Set<PrimitiveFieldValue> = new Set()
16
+ let selectedOptions: Set<JsonValue> = new Set()
17
17
 
18
18
  $: hasOptions = Array.isArray(field?.options) && field.options.length > 0
19
19
  $: staticOptions = Array.isArray(field?.options) ? field.options : null
@@ -22,7 +22,8 @@
22
22
  /**
23
23
  * Formats a response value for display, handling arrays, objects, and primitives.
24
24
  *
25
- * @param value - The response value to format.
25
+ * @param {unknown} value - The response value to format.
26
+ * @returns {string} The display string for the value.
26
27
  * @example
27
28
  * ```typescript
28
29
  * formatValue(['a', 'b']) // 'a, b'
@@ -87,13 +88,13 @@
87
88
  /**
88
89
  * Toggles selection of a field option, supporting both single and multi-select modes.
89
90
  *
90
- * @param optionValue - The option value to toggle.
91
+ * @param {JsonValue} optionValue - The option value to toggle.
91
92
  * @example
92
93
  * ```typescript
93
94
  * toggleOption('red') // selects or deselects the 'red' option
94
95
  * ```
95
96
  */
96
- function toggleOption(optionValue: PrimitiveFieldValue) {
97
+ function toggleOption(optionValue: JsonValue) {
97
98
  if (field?.multiple) {
98
99
  if (selectedOptions.has(optionValue)) {
99
100
  selectedOptions.delete(optionValue)
@@ -110,14 +111,15 @@
110
111
  /**
111
112
  * Parses a string input into a typed value based on the field's type.
112
113
  *
113
- * @param input - The raw string input to parse.
114
+ * @param {string} input - The raw string input to parse.
115
+ * @returns {FieldValue} The parsed value (null, number, boolean, JSON, or string).
114
116
  * @example
115
117
  * ```typescript
116
118
  * parseValue('42') // 42 (when field.type is 'number')
117
119
  * parseValue('true') // true (when field.type is 'boolean')
118
120
  * ```
119
121
  */
120
- function parseValue(input: string): unknown {
122
+ function parseValue(input: string): FieldValue {
121
123
  const trimmed = input.trim()
122
124
 
123
125
  if (trimmed === '' || trimmed === '-') {
@@ -173,7 +175,7 @@
173
175
  newValue = parseValue(editValue)
174
176
  }
175
177
 
176
- const result = await client.responses.commit({ [field.id]: newValue })
178
+ const result = await client.responses.commit({ [field.key]: newValue })
177
179
 
178
180
  if (result.errors.length > 0) {
179
181
  editError = result.errors[0].userMessage
@@ -197,7 +199,7 @@
197
199
  * ```
198
200
  */
199
201
  function handleClear() {
200
- client.responses.clear(field.id)
202
+ client.responses.clear(field.key)
201
203
  }
202
204
  </script>
203
205
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/svelte",
3
- "version": "0.0.62-next.7",
3
+ "version": "0.0.62-next.9",
4
4
  "dependencies": {
5
5
  "d3": "^7.9.0"
6
6
  },
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "module": "./dist/index.js",
90
90
  "peerDependencies": {
91
- "@picked/client": "0.0.62-next.7",
91
+ "@picked/client": "0.0.62-next.9",
92
92
  "effector": "^23.3.0",
93
93
  "svelte": "^5.46.4"
94
94
  },