@dxtmisha/scripts 0.8.2 → 0.8.3
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.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxtmisha/scripts",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Development scripts and CLI tools for DXT UI projects - automated component generation, library building and project management tools",
|
|
7
7
|
"keywords": [
|
|
@@ -7,6 +7,13 @@ import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
|
7
7
|
|
|
8
8
|
import type { LibraryData } from '../../types/libraryTypes'
|
|
9
9
|
import type { WebTypesAttributeItem, WebTypesAttributes, WebTypesEvents, WebTypesSlots, WebTypesTagItem } from '../../types/webTypes'
|
|
10
|
+
import { forEach } from '@dxtmisha/functional-basic'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* List of basic types that do not need to be wrapped in quotes for web-types/
|
|
14
|
+
* Список базовых типов, которые не нужно оборачивать в кавычки для web-types
|
|
15
|
+
*/
|
|
16
|
+
const BASE_TYPES = /^(boolean|number|string|null|any|void|object|unknown|never)$/
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
19
|
* Resolver for extracting and formatting IDE metadata for a specific component.
|
|
@@ -78,13 +85,14 @@ export class DesignWikiStormItem {
|
|
|
78
85
|
* @param item prop item / элемент свойства
|
|
79
86
|
*/
|
|
80
87
|
getAttribute(item: WikiStorybookProp): WebTypesAttributeItem {
|
|
88
|
+
const type = this.prepareType(item.getType())
|
|
81
89
|
return {
|
|
82
90
|
name: item.getName(),
|
|
83
91
|
description: item.getDescription(),
|
|
84
|
-
default: item.getDefaultValue(),
|
|
92
|
+
// default: item.getDefaultValue(),
|
|
85
93
|
value: {
|
|
86
94
|
kind: 'expression',
|
|
87
|
-
type
|
|
95
|
+
type
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
}
|
|
@@ -120,8 +128,8 @@ export class DesignWikiStormItem {
|
|
|
120
128
|
|
|
121
129
|
data.slots.forEach(
|
|
122
130
|
props => slots.push({
|
|
123
|
-
name: props.name,
|
|
124
|
-
description: props.description,
|
|
131
|
+
'name': props.name,
|
|
132
|
+
'description': props.description,
|
|
125
133
|
'vue-properties': props.properties ?? []
|
|
126
134
|
})
|
|
127
135
|
)
|
|
@@ -224,6 +232,36 @@ export class DesignWikiStormItem {
|
|
|
224
232
|
]
|
|
225
233
|
}
|
|
226
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Formats a type string for web-types.
|
|
237
|
+
*
|
|
238
|
+
* Форматирует строку типа для web-types.
|
|
239
|
+
* @param type original type string / исходная строка типа
|
|
240
|
+
*/
|
|
241
|
+
protected prepareType(type?: string): string | undefined {
|
|
242
|
+
if (type) {
|
|
243
|
+
return forEach(
|
|
244
|
+
type.split('|'),
|
|
245
|
+
(item) => {
|
|
246
|
+
const trimmed = item.trim()
|
|
247
|
+
|
|
248
|
+
if (trimmed === 'undefined') {
|
|
249
|
+
return undefined
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (BASE_TYPES.test(trimmed)) {
|
|
253
|
+
return trimmed
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return `'${trimmed}'`
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
.join(' | ')
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return type
|
|
263
|
+
}
|
|
264
|
+
|
|
227
265
|
/**
|
|
228
266
|
* Initializes the wiki object.
|
|
229
267
|
*
|
package/src/types/webTypes.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type WebTypesProperties = WebTypesProperty[]
|
|
|
25
25
|
*
|
|
26
26
|
* Вид значения атрибута.
|
|
27
27
|
*/
|
|
28
|
-
export type WebTypesAttributeKind = 'expression' | 'string'
|
|
28
|
+
export type WebTypesAttributeKind = 'expression' | 'plainText' | 'string'
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Attribute definition for a tag.
|