Skip to content

Commit d4f7bbe

Browse files
committedMar 26, 2024·
fix(kit/applet): parse state field types, closes #295
1 parent ad832b7 commit d4f7bbe

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed
 

‎packages/applet/src/components/state/StateFieldViewer.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ const normalizedDisplayedValue = computed(() => {
6868
}
6969
7070
else {
71-
const _value = type.value === 'custom' && !(props.data.value as InspectorCustomState)._custom?.type ? `"${displayedValue.value}"` : (displayedValue.value === '' ? `""` : displayedValue.value)
72-
const result = `<span class="${type.value}-state-type">${_value}</span>`
71+
const _type = (props.data.value as InspectorCustomState)._custom?.type
72+
const _value = type.value === 'custom' && !_type ? `"${displayedValue.value}"` : (displayedValue.value === '' ? `""` : displayedValue.value)
73+
const normalizedType = type.value === 'custom' && _type === 'ref' ? getInspectorStateValueType(_value) : type.value
74+
const result = `<span class="${normalizedType}-state-type">${_value}</span>`
7375
7476
if (extraDisplayedValue)
7577
return `${result} <span class="text-gray-500">(${extraDisplayedValue})</span>`

‎packages/applet/uno.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ export default defineConfig(mergeConfigs([unoConfig, {
5252
'string-state-type': 'text-#e74c3c dark:(text-#c41a16)',
5353
'literal-state-type': 'text-#03c dark:(text-#997fff)',
5454
'boolean-state-type': 'text-#27ae60 dark:(text-#abebc6)',
55+
'null-state-type': 'text-#999',
5556
}, [/^theme-card-(\w+)$/, $ => `p2 flex gap2 border border-base bg-base items-center rounded min-w-40 min-h-25 justify-center transition-all saturate-0 op50 shadow hover:(op100 bg-${$[1]}/10 text-${$[1]}6 saturate-100)`]],
5657
safelist: [
5758
'string-state-type',
5859
'literal-state-type',
5960
'boolean-state-type',
61+
'null-state-type',
6062
],
6163
}])) as any

‎packages/devtools-kit/src/core/component/state/format.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { reviver } from './reviver'
66

77
export function getInspectorStateValueType(value, raw = true) {
88
const type = typeof value
9-
if (value == null || value === UNDEFINED) {
9+
if (value == null || value === UNDEFINED || value === 'undefined') {
1010
return 'null'
1111
}
1212
else if (

0 commit comments

Comments
 (0)
Please sign in to comment.