@dxtmisha/scripts 0.11.8 → 1.0.0
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/CHANGELOG.md +57 -0
- package/ai-resources/componentMaterials.md +19 -0
- package/ai-resources/componentPrompt.md +381 -0
- package/ai-resources/componentWiki.md +13 -0
- package/bin/arguments.ts +168 -0
- package/bin/build-packages.ts +12 -2
- package/bin/build-publish-packages.ts +12 -2
- package/bin/design-component.ts +7 -1
- package/bin/design-constructor.ts +22 -3
- package/bin/design-figma.ts +26 -4
- package/bin/design-flags.ts +14 -2
- package/bin/design-library.ts +7 -1
- package/bin/design-package.ts +29 -5
- package/bin/design-prompt.ts +22 -3
- package/bin/design-screenshot.ts +12 -2
- package/bin/design-types-save.ts +32 -5
- package/bin/design-types.ts +32 -6
- package/bin/design-ui.ts +21 -3
- package/bin/design-wiki-storm.ts +11 -3
- package/dist/AiZAi-x3CInynJ.js +232 -0
- package/dist/PropertiesConfig-ChizwW5y.js +250 -0
- package/{src/config.ts → dist/config.d.ts} +179 -158
- package/dist/config.js +20 -0
- package/dist/figmaApiTypes-CArSsNW8.js +6 -0
- package/dist/library-ai.d.ts +482 -0
- package/dist/library-ai.js +2 -0
- package/dist/library-figma.d.ts +462 -0
- package/dist/library-figma.js +75 -0
- package/dist/library-ui.d.ts +586 -0
- package/dist/library-ui.js +3760 -0
- package/dist/library.d.ts +4677 -0
- package/dist/library.js +1436 -0
- package/dist/propertyTypes-DflziKuR.js +236 -0
- package/package.json +69 -20
- package/bin/ai-doc.ts +0 -7
- package/bin/build-functional.ts +0 -5
- package/bin/design-component-wiki.ts +0 -11
- package/src/classes/Ai/AiAbstract.ts +0 -242
- package/src/classes/Ai/AiClaude.ts +0 -26
- package/src/classes/Ai/AiClaudeAgent.ts +0 -16
- package/src/classes/Ai/AiClaudeAgentLite.ts +0 -86
- package/src/classes/Ai/AiClaudeCli.ts +0 -24
- package/src/classes/Ai/AiClaudeCliLite.ts +0 -108
- package/src/classes/Ai/AiClaudeLite.ts +0 -112
- package/src/classes/Ai/AiDoc.ts +0 -81
- package/src/classes/Ai/AiDocItem.ts +0 -27
- package/src/classes/Ai/AiDocItemAbstract.ts +0 -209
- package/src/classes/Ai/AiDocItemClasses.ts +0 -27
- package/src/classes/Ai/AiDocItemComposables.ts +0 -20
- package/src/classes/Ai/AiDocType.ts +0 -45
- package/src/classes/Ai/AiGoogle.ts +0 -26
- package/src/classes/Ai/AiGoogleCli.ts +0 -24
- package/src/classes/Ai/AiGoogleCliLite.ts +0 -108
- package/src/classes/Ai/AiGoogleLite.ts +0 -78
- package/src/classes/Ai/AiOpenAi.ts +0 -26
- package/src/classes/Ai/AiOpenAiLite.ts +0 -107
- package/src/classes/Ai/AiZAi.ts +0 -17
- package/src/classes/Ai/AiZAiLite.ts +0 -77
- package/src/classes/Ai/ApiTmp.ts +0 -43
- package/src/classes/BrowserItem.ts +0 -408
- package/src/classes/Build/BuildFunctional.ts +0 -54
- package/src/classes/Build/BuildPackages.ts +0 -137
- package/src/classes/Build/BuildPublishPackages.ts +0 -105
- package/src/classes/BuildItem.ts +0 -187
- package/src/classes/Component/ComponentCreator.ts +0 -45
- package/src/classes/Component/ComponentItem.ts +0 -161
- package/src/classes/Component/ComponentWiki.ts +0 -258
- package/src/classes/Component/ComponentWikiFile.ts +0 -138
- package/src/classes/Design/DesignCommand.ts +0 -243
- package/src/classes/Design/DesignComponent.ts +0 -824
- package/src/classes/Design/DesignConstructor.ts +0 -222
- package/src/classes/Design/DesignConstructors.ts +0 -101
- package/src/classes/Design/DesignFigma.ts +0 -61
- package/src/classes/Design/DesignFlags.ts +0 -215
- package/src/classes/Design/DesignReplace.ts +0 -672
- package/src/classes/Design/DesignScreenshot.ts +0 -140
- package/src/classes/Design/DesignStructure.ts +0 -201
- package/src/classes/Design/DesignStructureClasses.ts +0 -105
- package/src/classes/Design/DesignStructureItemAbstract.ts +0 -52
- package/src/classes/Design/DesignStructureRead.ts +0 -349
- package/src/classes/Design/DesignStructureStyles.ts +0 -45
- package/src/classes/Design/DesignTypes.ts +0 -94
- package/src/classes/Design/DesignTypesAi.ts +0 -135
- package/src/classes/Design/DesignTypesDescription.ts +0 -121
- package/src/classes/Design/DesignTypesMake.ts +0 -460
- package/src/classes/Design/DesignTypesMcp.ts +0 -90
- package/src/classes/Design/DesignTypesPrompts.ts +0 -332
- package/src/classes/Design/DesignTypescript.ts +0 -244
- package/src/classes/Design/DesignUi.ts +0 -143
- package/src/classes/Design/DesignWiki.ts +0 -52
- package/src/classes/Design/DesignWikiStorm.ts +0 -95
- package/src/classes/Design/DesignWikiStormItem.ts +0 -316
- package/src/classes/FigmaApi.ts +0 -190
- package/src/classes/Git/GitRead.ts +0 -261
- package/src/classes/Library/LibraryAiMcpItem.ts +0 -67
- package/src/classes/Library/LibraryAiPrompt.ts +0 -268
- package/src/classes/Library/LibraryAiPromptItem.ts +0 -331
- package/src/classes/Library/LibraryAiWiki.ts +0 -127
- package/src/classes/Library/LibraryAiWikiItem.ts +0 -79
- package/src/classes/Library/LibraryExport.ts +0 -167
- package/src/classes/Library/LibraryFlags.ts +0 -62
- package/src/classes/Library/LibraryItems.ts +0 -138
- package/src/classes/Library/LibraryList.ts +0 -189
- package/src/classes/Library/LibraryMedia.ts +0 -139
- package/src/classes/Library/LibraryPlugin.ts +0 -73
- package/src/classes/Library/LibraryTypes.ts +0 -130
- package/src/classes/Package/PackageFile.ts +0 -154
- package/src/classes/Package/PackageInit.ts +0 -54
- package/src/classes/Package/PackageItem.ts +0 -329
- package/src/classes/Properties/Properties.ts +0 -175
- package/src/classes/Properties/PropertiesCache.ts +0 -248
- package/src/classes/Properties/PropertiesConfig.ts +0 -213
- package/src/classes/Properties/PropertiesConvector.ts +0 -52
- package/src/classes/Properties/PropertiesFile.ts +0 -522
- package/src/classes/Properties/PropertiesImport.ts +0 -182
- package/src/classes/Properties/PropertiesItems.ts +0 -605
- package/src/classes/Properties/PropertiesKeys.ts +0 -121
- package/src/classes/Properties/PropertiesMain.ts +0 -138
- package/src/classes/Properties/PropertiesPalette.ts +0 -149
- package/src/classes/Properties/PropertiesPath.ts +0 -193
- package/src/classes/Properties/PropertiesScss.ts +0 -261
- package/src/classes/Properties/PropertiesSeparator.ts +0 -118
- package/src/classes/Properties/PropertiesSettings.ts +0 -104
- package/src/classes/Properties/PropertiesStandard.ts +0 -180
- package/src/classes/Properties/PropertiesTool.ts +0 -80
- package/src/classes/Properties/PropertiesTypes.ts +0 -147
- package/src/classes/Properties/PropertiesValues.ts +0 -75
- package/src/classes/Properties/PropertiesWrap.ts +0 -187
- package/src/classes/Properties/convector/convectorColor.ts +0 -27
- package/src/classes/Properties/convector/convectorFontFamilies.ts +0 -18
- package/src/classes/Properties/convector/convectorShadow.ts +0 -61
- package/src/classes/Properties/convector/convectorTypography.ts +0 -19
- package/src/classes/Properties/to/PropertiesToAbstract.ts +0 -51
- package/src/classes/Properties/to/PropertiesToAnimate.ts +0 -59
- package/src/classes/Properties/to/PropertiesToClass.ts +0 -49
- package/src/classes/Properties/to/PropertiesToClone.ts +0 -114
- package/src/classes/Properties/to/PropertiesToComponent.ts +0 -52
- package/src/classes/Properties/to/PropertiesToDrag.ts +0 -231
- package/src/classes/Properties/to/PropertiesToDuplicate.ts +0 -165
- package/src/classes/Properties/to/PropertiesToFull.ts +0 -36
- package/src/classes/Properties/to/PropertiesToLink.ts +0 -259
- package/src/classes/Properties/to/PropertiesToMedia.ts +0 -187
- package/src/classes/Properties/to/PropertiesToMulti.ts +0 -101
- package/src/classes/Properties/to/PropertiesToNone.ts +0 -46
- package/src/classes/Properties/to/PropertiesToPalette.ts +0 -241
- package/src/classes/Properties/to/PropertiesToProperty.ts +0 -31
- package/src/classes/Properties/to/PropertiesToRemove.ts +0 -33
- package/src/classes/Properties/to/PropertiesToReplace.ts +0 -77
- package/src/classes/Properties/to/PropertiesToRoot.ts +0 -40
- package/src/classes/Properties/to/PropertiesToSimilar.ts +0 -128
- package/src/classes/Properties/to/PropertiesToSort.ts +0 -146
- package/src/classes/Properties/to/PropertiesToState.ts +0 -65
- package/src/classes/Properties/to/PropertiesToStyle.ts +0 -52
- package/src/classes/Properties/to/PropertiesToSub.ts +0 -95
- package/src/classes/Properties/to/PropertiesToSubclass.ts +0 -76
- package/src/classes/Properties/to/PropertiesToVar.ts +0 -194
- package/src/classes/Properties/to/PropertiesToVariable.ts +0 -176
- package/src/classes/Styles/Styles.ts +0 -247
- package/src/classes/Styles/StylesClasses.ts +0 -86
- package/src/classes/Styles/StylesProperties.ts +0 -197
- package/src/classes/Styles/StylesRoot.ts +0 -103
- package/src/classes/Styles/StylesTool.ts +0 -112
- package/src/classes/Styles/to/StylesToAbstract.ts +0 -93
- package/src/classes/Styles/to/StylesToAnimate.ts +0 -19
- package/src/classes/Styles/to/StylesToClass.ts +0 -25
- package/src/classes/Styles/to/StylesToClassFull.ts +0 -19
- package/src/classes/Styles/to/StylesToContainer.ts +0 -24
- package/src/classes/Styles/to/StylesToMedia.ts +0 -19
- package/src/classes/Styles/to/StylesToProperty.ts +0 -123
- package/src/classes/Styles/to/StylesToRoot.ts +0 -14
- package/src/classes/Styles/to/StylesToSelector.ts +0 -71
- package/src/classes/Styles/to/StylesToVar.ts +0 -105
- package/src/classes/Styles/to/StylesToVirtual.ts +0 -33
- package/src/composables/useAi.ts +0 -38
- package/src/demo/ai.ts +0 -10
- package/src/functions/getComponentPaths.ts +0 -13
- package/src/functions/getConfigAi.ts +0 -14
- package/src/functions/getConstructorProperties.ts +0 -54
- package/src/functions/getDirname.ts +0 -17
- package/src/functions/getNameDirByPaths.ts +0 -16
- package/src/functions/getPackageJson.ts +0 -19
- package/src/functions/hasNativeDirname.ts +0 -8
- package/src/functions/run.ts +0 -47
- package/src/functions/toPathStandardSep.ts +0 -14
- package/src/library-ai.ts +0 -10
- package/src/library.ts +0 -73
- package/src/media/ai/ai-doc-types.ts +0 -21
- package/src/media/properties/css.ts +0 -634
- package/src/media/properties/cssSelector.ts +0 -74
- package/src/media/properties/cssVirtual.ts +0 -12
- package/src/media/properties/listSort.ts +0 -113
- package/src/media/properties/style.ts +0 -81
- package/src/media/templates/component/DesignComponent.mdx +0 -30
- package/src/media/templates/component/DesignComponent.stories.ts +0 -34
- package/src/media/templates/component/DesignComponent.vue +0 -54
- package/src/media/templates/component/DesignComponentAiWiki.vue +0 -25
- package/src/media/templates/component/index.ts +0 -13
- package/src/media/templates/component/props.ts +0 -27
- package/src/media/templates/component/styleToken.scss +0 -17
- package/src/media/templates/component/wiki.ts +0 -13
- package/src/media/templates/component/wikiData.ts +0 -28
- package/src/media/templates/componentDoc/ComponentDoc.vue +0 -26
- package/src/media/templates/componentDoc/index.ts +0 -12
- package/src/media/templates/componentDoc/materials/README.md +0 -8
- package/src/media/templates/componentDoc/materials/prompt.md +0 -38
- package/src/media/templates/componentDoc/subcomponents/_.gitignore.txt +0 -0
- package/src/media/templates/componentDoc/types.ts +0 -15
- package/src/media/templates/componentDoc/wiki/ComponentDoc.mdx +0 -13
- package/src/media/templates/componentDoc/wiki/ComponentDoc.stories.ts +0 -24
- package/src/media/templates/componentDoc/wiki/prompt.md +0 -41
- package/src/media/templates/constructors/Constructors.ts +0 -33
- package/src/media/templates/constructors/ConstructorsDesign.tsx +0 -129
- package/src/media/templates/constructors/basicTypes.ts +0 -0
- package/src/media/templates/constructors/index.ts +0 -5
- package/src/media/templates/constructors/props.ts +0 -28
- package/src/media/templates/constructors/style.scss +0 -5
- package/src/media/templates/constructors/types.ts +0 -47
- package/src/media/templates/packages/figma/README.md +0 -1
- package/src/media/templates/packages/figma/_.gitignore.txt +0 -29
- package/src/media/templates/packages/figma/ai.sample.config.ts +0 -2
- package/src/media/templates/packages/figma/design.config.json +0 -3
- package/src/media/templates/packages/figma/index.html +0 -12
- package/src/media/templates/packages/figma/manifest.json +0 -25
- package/src/media/templates/packages/figma/package.json +0 -37
- package/src/media/templates/packages/figma/src/App.vue +0 -9
- package/src/media/templates/packages/figma/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/code.ts +0 -16
- package/src/media/templates/packages/figma/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/config.ts +0 -0
- package/src/media/templates/packages/figma/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/library.ts +0 -0
- package/src/media/templates/packages/figma/src/main.ts +0 -4
- package/src/media/templates/packages/figma/src/media/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/storybook/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/figma/tsconfig.app.json +0 -12
- package/src/media/templates/packages/figma/tsconfig.json +0 -7
- package/src/media/templates/packages/figma/tsconfig.node.json +0 -8
- package/src/media/templates/packages/figma/vite.config.ts +0 -7
- package/src/media/templates/packages/library/README.md +0 -1
- package/src/media/templates/packages/library/_.gitignore.txt +0 -27
- package/src/media/templates/packages/library/ai-description.md +0 -15
- package/src/media/templates/packages/library/design.config.json +0 -3
- package/src/media/templates/packages/library/index.html +0 -12
- package/src/media/templates/packages/library/materials/README.md +0 -8
- package/src/media/templates/packages/library/materials/prompt.md +0 -45
- package/src/media/templates/packages/library/package.json +0 -46
- package/src/media/templates/packages/library/src/App.vue +0 -8
- package/src/media/templates/packages/library/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/library.ts +0 -0
- package/src/media/templates/packages/library/src/main.ts +0 -6
- package/src/media/templates/packages/library/src/style.scss +0 -0
- package/src/media/templates/packages/library/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/library/tsconfig.app.json +0 -11
- package/src/media/templates/packages/library/tsconfig.json +0 -7
- package/src/media/templates/packages/library/tsconfig.node.json +0 -7
- package/src/media/templates/packages/library/vite.config.ts +0 -14
- package/src/media/templates/packages/nitro/README.md +0 -1
- package/src/media/templates/packages/nitro/_.gitignore.txt +0 -28
- package/src/media/templates/packages/nitro/index.html +0 -2
- package/src/media/templates/packages/nitro/package.json +0 -25
- package/src/media/templates/packages/nitro/server/plugins/ui-plugin.ts +0 -7
- package/src/media/templates/packages/nitro/server/routes/api/hello.ts +0 -13
- package/src/media/templates/packages/nitro/src/App.vue +0 -10
- package/src/media/templates/packages/nitro/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/entry-client.ts +0 -13
- package/src/media/templates/packages/nitro/src/entry-server.ts +0 -29
- package/src/media/templates/packages/nitro/src/main.ts +0 -14
- package/src/media/templates/packages/nitro/src/pages/HomePage.vue +0 -8
- package/src/media/templates/packages/nitro/src/router.ts +0 -11
- package/src/media/templates/packages/nitro/src/style.scss +0 -0
- package/src/media/templates/packages/nitro/src/templates/main.html +0 -21
- package/src/media/templates/packages/nitro/src/vite-env.d.ts +0 -11
- package/src/media/templates/packages/nitro/tsconfig.app.json +0 -14
- package/src/media/templates/packages/nitro/tsconfig.json +0 -7
- package/src/media/templates/packages/nitro/tsconfig.node.json +0 -12
- package/src/media/templates/packages/nitro/vite.config.ts +0 -17
- package/src/media/templates/packages/project/README.md +0 -1
- package/src/media/templates/packages/project/_.gitignore.txt +0 -28
- package/src/media/templates/packages/project/design.config.json +0 -3
- package/src/media/templates/packages/project/index.html +0 -12
- package/src/media/templates/packages/project/materials/README.md +0 -8
- package/src/media/templates/packages/project/materials/prompt.md +0 -41
- package/src/media/templates/packages/project/package.json +0 -13
- package/src/media/templates/packages/project/public/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/App.vue +0 -12
- package/src/media/templates/packages/project/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/main.ts +0 -6
- package/src/media/templates/packages/project/src/style.scss +0 -0
- package/src/media/templates/packages/project/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/project/tsconfig.app.json +0 -11
- package/src/media/templates/packages/project/tsconfig.json +0 -7
- package/src/media/templates/packages/project/tsconfig.node.json +0 -7
- package/src/media/templates/packages/project/vite.config.ts +0 -7
- package/src/media/templates/prompts/aiCodeGlobalPrompt.en.md +0 -22
- package/src/media/templates/prompts/aiCodeGlobalPrompt.ru.md +0 -21
- package/src/media/templates/prompts/aiCodeVuePrompt.en.md +0 -17
- package/src/media/templates/prompts/aiCodeVuePrompt.ru.md +0 -17
- package/src/media/templates/prompts/aiDocClassPrompt.en.txt +0 -63
- package/src/media/templates/prompts/aiDocClassPrompt.ru.txt +0 -63
- package/src/media/templates/prompts/aiDocComposablePrompt.en.txt +0 -67
- package/src/media/templates/prompts/aiDocComposablePrompt.ru.txt +0 -67
- package/src/media/templates/prompts/aiDocFunctionPrompt.en.txt +0 -57
- package/src/media/templates/prompts/aiDocFunctionPrompt.ru.txt +0 -57
- package/src/media/templates/prompts/componentPrompt.en.txt +0 -182
- package/src/media/templates/prompts/componentPrompt.ru.txt +0 -182
- package/src/media/templates/prompts/demoClassEn.mdx +0 -111
- package/src/media/templates/prompts/demoClassRu.mdx +0 -111
- package/src/media/templates/prompts/demoComponentEn.mdx +0 -282
- package/src/media/templates/prompts/demoComponentRu.mdx +0 -282
- package/src/media/templates/prompts/demoComposableEn.mdx +0 -103
- package/src/media/templates/prompts/demoComposableRu.mdx +0 -103
- package/src/media/templates/prompts/demoDocEn.mdx +0 -30
- package/src/media/templates/prompts/demoDocRu.mdx +0 -30
- package/src/media/templates/viteComponentTemplateConfig.ts +0 -14
- package/src/types/aiTypes.ts +0 -19
- package/src/types/configTypes.ts +0 -69
- package/src/types/designTypes.ts +0 -167
- package/src/types/figmaApiTypes.ts +0 -337
- package/src/types/gitTypes.ts +0 -59
- package/src/types/libraryTypes.ts +0 -49
- package/src/types/propertyTypes.ts +0 -586
- package/src/types/screenshotTypes.ts +0 -55
- package/src/types/webTypes.ts +0 -134
- package/src/vite-env.d.ts +0 -1
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { forEach, isFilled, isObject, isObjectNotArray } from '@dxtmisha/functional-basic'
|
|
4
|
-
|
|
5
|
-
import { PropertiesToAbstract } from './PropertiesToAbstract'
|
|
6
|
-
import { PropertiesItems } from '../PropertiesItems'
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
PropertyCategory,
|
|
10
|
-
type PropertyItem,
|
|
11
|
-
type PropertyItemsItem,
|
|
12
|
-
PropertyKey,
|
|
13
|
-
type PropertyList,
|
|
14
|
-
PropertyType
|
|
15
|
-
} from '../../../types/propertyTypes'
|
|
16
|
-
|
|
17
|
-
const THEME_BASIC = 'basic'
|
|
18
|
-
const KEY_CLASS_NAME = 'palette'
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Class for working with colors.
|
|
22
|
-
*
|
|
23
|
-
* Класс для работы с цветами.
|
|
24
|
-
*/
|
|
25
|
-
export class PropertiesToPalette extends PropertiesToAbstract {
|
|
26
|
-
protected readonly FILE_CACHE = '002-palette'
|
|
27
|
-
private palette: PropertyItemsItem[]
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Constructor
|
|
31
|
-
* @param items data for processing/ данные для обработки
|
|
32
|
-
*/
|
|
33
|
-
constructor(protected items: PropertiesItems) {
|
|
34
|
-
super(items)
|
|
35
|
-
this.palette = this.items.findCategory(PropertyCategory.palette)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Adding a class for working with colors.
|
|
40
|
-
*
|
|
41
|
-
* Добавление класса для работы со цветами.
|
|
42
|
-
*/
|
|
43
|
-
protected init(): void {
|
|
44
|
-
this.read()
|
|
45
|
-
this.items.findCategory(PropertyCategory.theme)
|
|
46
|
-
.forEach(({
|
|
47
|
-
design,
|
|
48
|
-
name,
|
|
49
|
-
item
|
|
50
|
-
}) => item?.value && isObjectNotArray(item.value) && this.read(item.value, name, design))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Adding a group of properties based on the design name.
|
|
55
|
-
*
|
|
56
|
-
* Добавление группы свойств по названию дизайна.
|
|
57
|
-
* @param category category names/ названия категорий
|
|
58
|
-
* @param parent the property object, by which it will be added/ объект свойства, по которому будет добавлять
|
|
59
|
-
*/
|
|
60
|
-
private getParent(
|
|
61
|
-
category: PropertyCategory.colors | PropertyCategory.class,
|
|
62
|
-
parent: PropertyList
|
|
63
|
-
): PropertyList {
|
|
64
|
-
if (!(KEY_CLASS_NAME in parent)) {
|
|
65
|
-
parent[KEY_CLASS_NAME] = {
|
|
66
|
-
value: {},
|
|
67
|
-
[PropertyKey.type]: category === PropertyCategory.colors
|
|
68
|
-
? PropertyType.classType
|
|
69
|
-
: PropertyType.component,
|
|
70
|
-
[PropertyKey.category]: category
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return parent[KEY_CLASS_NAME].value as PropertyList
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Adding a new class with the name of the color.
|
|
79
|
-
*
|
|
80
|
-
* Добавление нового класса по имени цвета.
|
|
81
|
-
* @param items list of classes/ список классов
|
|
82
|
-
* @param name class name/ название класса
|
|
83
|
-
*/
|
|
84
|
-
private getClass(items: PropertyList, name: string): PropertyList {
|
|
85
|
-
if (!items?.[name]) {
|
|
86
|
-
items[name] = {
|
|
87
|
-
value: {},
|
|
88
|
-
[PropertyKey.type]: PropertyType.state
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return items[name].value as PropertyList
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Returns names for light.
|
|
97
|
-
*
|
|
98
|
-
* Возвращает названия для света.
|
|
99
|
-
* @param theme the name of the theme/ название темы
|
|
100
|
-
* @param name names of colors/ названия цвета
|
|
101
|
-
*/
|
|
102
|
-
private getName(theme: string, name: string): string {
|
|
103
|
-
return `${theme}-${name}`
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Returns values for color.
|
|
108
|
-
*
|
|
109
|
-
* Возвращает значения для цвета.
|
|
110
|
-
* @param link base link/ базовая ссылка
|
|
111
|
-
* @param name names of colors/ названия цвета
|
|
112
|
-
*/
|
|
113
|
-
private getValue(link: string, name: string): string {
|
|
114
|
-
return `{${link}.${name}}`
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Checking the default value.
|
|
119
|
-
*
|
|
120
|
-
* Проверка значения по умолчанию.
|
|
121
|
-
* @param item the value to be checked/ проверяемое значение
|
|
122
|
-
* @param theme the name of the theme/ название темы
|
|
123
|
-
*/
|
|
124
|
-
private getValueDefault(item: PropertyItem, theme: string): string {
|
|
125
|
-
const value = item?.[PropertyKey.default]
|
|
126
|
-
|
|
127
|
-
if (isFilled(value)) {
|
|
128
|
-
return isObject(value) ? value?.[theme] : value as string
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return 'default'
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Adding a color property by the name of the theme.
|
|
136
|
-
*
|
|
137
|
-
* Добавление свойства цвета по названию темы.
|
|
138
|
-
* @param root the property object, by which it will be added/
|
|
139
|
-
* объект свойства, по которому будет добавлять
|
|
140
|
-
* @param theme the name of the theme/ название темы
|
|
141
|
-
* @param designParent design name/ название дизайна
|
|
142
|
-
*/
|
|
143
|
-
private read(
|
|
144
|
-
root?: PropertyList,
|
|
145
|
-
theme = THEME_BASIC,
|
|
146
|
-
designParent?: string
|
|
147
|
-
) {
|
|
148
|
-
this.palette.forEach(({
|
|
149
|
-
design,
|
|
150
|
-
item,
|
|
151
|
-
parents,
|
|
152
|
-
index
|
|
153
|
-
}) => {
|
|
154
|
-
if (!designParent || designParent === design) {
|
|
155
|
-
const themeName = item?.[PropertyKey.theme]
|
|
156
|
-
|
|
157
|
-
if (!themeName || themeName === theme) {
|
|
158
|
-
const list = this.getParent(
|
|
159
|
-
root ? PropertyCategory.colors : PropertyCategory.class,
|
|
160
|
-
root ?? (parents?.[0]?.item.value as PropertyList)
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
list
|
|
165
|
-
&& isObjectNotArray(item.value)
|
|
166
|
-
) {
|
|
167
|
-
forEach(item.value, (shade, name) => {
|
|
168
|
-
const parent = this.getClass(list, name)
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
isObjectNotArray(shade.value)
|
|
172
|
-
&& shade?.[PropertyKey.category] !== PropertyCategory.paletteNone
|
|
173
|
-
) {
|
|
174
|
-
this.addItem(
|
|
175
|
-
parent,
|
|
176
|
-
`${index}.${name}`,
|
|
177
|
-
theme,
|
|
178
|
-
shade.value
|
|
179
|
-
)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this.addDefault(parent, theme, item)
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Adding a saturation property.
|
|
192
|
-
*
|
|
193
|
-
* Добавление свойства насыщенности.
|
|
194
|
-
* @param parent list of available values for the class/ список доступных значений у класса
|
|
195
|
-
* @param link list of classes/ список классов
|
|
196
|
-
* @param theme the name of the theme/ название темы
|
|
197
|
-
* @param palette the list of saturation/ список насыщенности
|
|
198
|
-
* @private
|
|
199
|
-
*/
|
|
200
|
-
private addItem(
|
|
201
|
-
parent: PropertyList,
|
|
202
|
-
link: string,
|
|
203
|
-
theme: string,
|
|
204
|
-
palette: PropertyList
|
|
205
|
-
): void {
|
|
206
|
-
forEach(palette, (item, name) => {
|
|
207
|
-
if (item) {
|
|
208
|
-
parent[this.getName(theme, name)] = {
|
|
209
|
-
value: this.getValue(link, name),
|
|
210
|
-
[PropertyKey.type]: PropertyType.var,
|
|
211
|
-
[PropertyKey.category]: PropertyCategory.color
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Adding a default value.
|
|
219
|
-
*
|
|
220
|
-
* Добавление значения по умолчанию.
|
|
221
|
-
* @param parent list of available values for the class/ список доступных значений у класса
|
|
222
|
-
* @param theme the name of the theme/ название темы
|
|
223
|
-
* @param palette list of classes/ список классов
|
|
224
|
-
* @private
|
|
225
|
-
*/
|
|
226
|
-
private addDefault(
|
|
227
|
-
parent: PropertyList,
|
|
228
|
-
theme: string,
|
|
229
|
-
palette: PropertyItem
|
|
230
|
-
): void {
|
|
231
|
-
const defaultValue = this.getValueDefault(palette, theme)
|
|
232
|
-
const name = this.getName(theme, defaultValue)
|
|
233
|
-
|
|
234
|
-
if (parent?.[name]) {
|
|
235
|
-
parent['sys-palette'] = {
|
|
236
|
-
...parent[name],
|
|
237
|
-
[PropertyKey.fullName]: true
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { toKebabCase } from '@dxtmisha/functional-basic'
|
|
4
|
-
|
|
5
|
-
import { PropertiesToVar } from './PropertiesToVar'
|
|
6
|
-
|
|
7
|
-
import { type PropertyItemsItem, PropertyType } from '../../../types/propertyTypes'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Class for working with custom styles in CSS.
|
|
11
|
-
*
|
|
12
|
-
* Класс для работы с пользовательскими стилями в CSS.
|
|
13
|
-
*/
|
|
14
|
-
export class PropertiesToProperty extends PropertiesToVar {
|
|
15
|
-
protected FILE_CACHE = '024-property'
|
|
16
|
-
protected type = PropertyType.property
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Name transformation for the var type.
|
|
20
|
-
*
|
|
21
|
-
* Преобразование имени для типа var.
|
|
22
|
-
* @param name base property name/ базовое название свойства
|
|
23
|
-
* @param item current element/ текущий элемент
|
|
24
|
-
*/
|
|
25
|
-
protected getName({
|
|
26
|
-
name,
|
|
27
|
-
item
|
|
28
|
-
}: PropertyItemsItem) {
|
|
29
|
-
return toKebabCase(this.items.getReName(name, item))
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { getColumn, isObjectNotArray } from '@dxtmisha/functional-basic'
|
|
4
|
-
|
|
5
|
-
import { PropertiesToAbstract } from './PropertiesToAbstract'
|
|
6
|
-
|
|
7
|
-
import { PropertyKey } from '../../../types/propertyTypes'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Class for removing a property.
|
|
11
|
-
*
|
|
12
|
-
* Класс для удаления свойства.
|
|
13
|
-
*/
|
|
14
|
-
export class PropertiesToRemove extends PropertiesToAbstract {
|
|
15
|
-
protected readonly FILE_CACHE = '007-02-remove'
|
|
16
|
-
|
|
17
|
-
protected init(): void {
|
|
18
|
-
this.items.find(({ item }) => item?.[PropertyKey.remove] ?? false)
|
|
19
|
-
.forEach(({
|
|
20
|
-
name,
|
|
21
|
-
parent,
|
|
22
|
-
parents
|
|
23
|
-
}) => {
|
|
24
|
-
if (
|
|
25
|
-
parent
|
|
26
|
-
&& isObjectNotArray(parent.value)
|
|
27
|
-
) {
|
|
28
|
-
console.warn('[Remove]', `{${getColumn(parents, 'name').join('.')}.${name}}`)
|
|
29
|
-
delete parent.value[name]
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { PropertiesToAbstract } from './PropertiesToAbstract'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
PropertyKey,
|
|
7
|
-
type PropertyReplace
|
|
8
|
-
} from '../../../types/propertyTypes'
|
|
9
|
-
|
|
10
|
-
export type PropertiesReplaceValue = string | Partial<PropertyReplace>
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A class for transforming an expression through regular expressions.
|
|
14
|
-
*
|
|
15
|
-
* Класс для преобразования выражения через регулярные выражения.
|
|
16
|
-
*/
|
|
17
|
-
export class PropertiesToReplace extends PropertiesToAbstract {
|
|
18
|
-
protected readonly FILE_CACHE = '001-replace'
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Transforming all of its properties.
|
|
22
|
-
*
|
|
23
|
-
* Преобразование всех своих свойств.
|
|
24
|
-
*/
|
|
25
|
-
protected init(): void {
|
|
26
|
-
this.items.each(({ item }) => {
|
|
27
|
-
if (
|
|
28
|
-
item?.[PropertyKey.replace]
|
|
29
|
-
&& typeof item.value === 'string'
|
|
30
|
-
) {
|
|
31
|
-
item.value = this.getValue(
|
|
32
|
-
this.getInfo(item[PropertyKey.replace]),
|
|
33
|
-
item.value
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
delete item[PropertyKey.replace]
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Getting information about the transformation.
|
|
43
|
-
*
|
|
44
|
-
* Получение информации о преобразовании.
|
|
45
|
-
* @param info information for verification/ информация для проверки
|
|
46
|
-
*/
|
|
47
|
-
private getInfo(info: PropertiesReplaceValue): PropertyReplace {
|
|
48
|
-
if (typeof info === 'object') {
|
|
49
|
-
return {
|
|
50
|
-
pattern: info?.pattern,
|
|
51
|
-
flags: info?.flags || 'i',
|
|
52
|
-
replace: info?.replace || '$1'
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
return {
|
|
56
|
-
pattern: info || undefined,
|
|
57
|
-
flags: 'i',
|
|
58
|
-
replace: '$1'
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Returns the transformed value.
|
|
65
|
-
*
|
|
66
|
-
* Возвращает преобразованное значение.
|
|
67
|
-
* @param info information for verification/ информация для проверки
|
|
68
|
-
* @param value
|
|
69
|
-
*/
|
|
70
|
-
private getValue(info: PropertyReplace, value: string): string {
|
|
71
|
-
if (info?.pattern) {
|
|
72
|
-
return value.replace(new RegExp(info.pattern, info.flags), info.replace)
|
|
73
|
-
} else {
|
|
74
|
-
return value
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { PropertiesToAbstract } from './PropertiesToAbstract'
|
|
4
|
-
|
|
5
|
-
import { PropertyKey, PropertyType } from '../../../types/propertyTypes'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A class for transforming class.
|
|
9
|
-
*
|
|
10
|
-
* Класс для преобразования class.
|
|
11
|
-
*/
|
|
12
|
-
export class PropertiesToRoot extends PropertiesToAbstract {
|
|
13
|
-
protected readonly FILE_CACHE = '038-root'
|
|
14
|
-
|
|
15
|
-
protected init(): void {
|
|
16
|
-
this.items.findVariable(PropertyType.root).forEach(({
|
|
17
|
-
design,
|
|
18
|
-
component,
|
|
19
|
-
name,
|
|
20
|
-
item
|
|
21
|
-
}) => {
|
|
22
|
-
if (component) {
|
|
23
|
-
item[PropertyKey.name] = this.getName(design, component, this.items.getReName(name, item))
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param design design name/ название дизайна
|
|
30
|
-
* @param component component name/ название компонента
|
|
31
|
-
* @param name base property name/ базовое название свойства
|
|
32
|
-
*/
|
|
33
|
-
private getName(
|
|
34
|
-
design: string,
|
|
35
|
-
component: string,
|
|
36
|
-
name: string
|
|
37
|
-
): string {
|
|
38
|
-
return `${this.items.getLink(design, component, name)} &`
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { isObjectNotArray } from '@dxtmisha/functional-basic'
|
|
4
|
-
|
|
5
|
-
import { PropertiesToAbstract } from './PropertiesToAbstract'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type PropertyItem,
|
|
9
|
-
type PropertyItemsParent,
|
|
10
|
-
PropertyKey,
|
|
11
|
-
PropertyType
|
|
12
|
-
} from '../../../types/propertyTypes'
|
|
13
|
-
|
|
14
|
-
const TYPE = [
|
|
15
|
-
PropertyType.var,
|
|
16
|
-
PropertyType.property
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
const EXCEPTION = [
|
|
20
|
-
PropertyType.classType,
|
|
21
|
-
PropertyType.subclass
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A class for searching for related properties at a higher level to adopt their properties.
|
|
26
|
-
*
|
|
27
|
-
* Класс для поиска родственных свойств на уровне выше для принятия их свойств.
|
|
28
|
-
*/
|
|
29
|
-
export class PropertiesToSimilar extends PropertiesToAbstract {
|
|
30
|
-
protected readonly FILE_CACHE = '010-similar'
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Finding similar data for editing.
|
|
34
|
-
*
|
|
35
|
-
* Поиск похожих данных для редактирования.
|
|
36
|
-
*/
|
|
37
|
-
protected init(): void {
|
|
38
|
-
this.items.each(({
|
|
39
|
-
item,
|
|
40
|
-
name,
|
|
41
|
-
parents
|
|
42
|
-
}) => {
|
|
43
|
-
const similar = this.getParent(name, item, parents)
|
|
44
|
-
|
|
45
|
-
if (similar) {
|
|
46
|
-
item[PropertyKey.rename] = this.items.getReName(name, similar)
|
|
47
|
-
item[PropertyKey.variable] = similar?.[PropertyKey.variable]
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Returns similar values by its name.
|
|
54
|
-
*
|
|
55
|
-
* Возвращает похожие значения по его имени.
|
|
56
|
-
* @param name name of the name/ название имени
|
|
57
|
-
* @param item object for checking/ объект для проверки
|
|
58
|
-
* @param parents array of all ancestor properties along the tree from the top level/
|
|
59
|
-
* массив со всеми свойствами предков по дереву от верхнего уровня
|
|
60
|
-
*/
|
|
61
|
-
private getParent(
|
|
62
|
-
name: string,
|
|
63
|
-
item: PropertyItem,
|
|
64
|
-
parents: PropertyItemsParent[]
|
|
65
|
-
): PropertyItem | undefined {
|
|
66
|
-
const list = [...parents].reverse()
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
!item?.[PropertyKey.type]
|
|
70
|
-
&& !item?.[PropertyKey.rename]
|
|
71
|
-
&& !this.isException(item)
|
|
72
|
-
&& !this.isException(list?.[0]?.item)
|
|
73
|
-
) {
|
|
74
|
-
list.shift()
|
|
75
|
-
|
|
76
|
-
for (const { item } of list) {
|
|
77
|
-
if (isObjectNotArray(item.value)) {
|
|
78
|
-
const similar = item.value?.[name]
|
|
79
|
-
|
|
80
|
-
if (this.isException(item)) {
|
|
81
|
-
break
|
|
82
|
-
} else if (
|
|
83
|
-
similar
|
|
84
|
-
&& this.is(similar) && (
|
|
85
|
-
similar?.[PropertyKey.type]
|
|
86
|
-
|| similar?.[PropertyKey.rename]
|
|
87
|
-
)
|
|
88
|
-
) {
|
|
89
|
-
return similar
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return undefined
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the property is available for inheritance.
|
|
100
|
-
*
|
|
101
|
-
* Проверяет, доступно ли свойство для наследования.
|
|
102
|
-
* @param item object for checking/ объект для проверки
|
|
103
|
-
*/
|
|
104
|
-
private is(item: PropertyItem): boolean {
|
|
105
|
-
if (item?.[PropertyKey.variable]) {
|
|
106
|
-
return TYPE.indexOf(item?.[PropertyKey.variable]) !== -1
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return false
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Checks if inheriting the property is prohibited.
|
|
114
|
-
*
|
|
115
|
-
* Проверяет, запрещено ли наследовать свойство.
|
|
116
|
-
* @param item object for checking/ объект для проверки
|
|
117
|
-
*/
|
|
118
|
-
private isException(item?: PropertyItem): boolean {
|
|
119
|
-
if (
|
|
120
|
-
item
|
|
121
|
-
&& item?.[PropertyKey.variable]
|
|
122
|
-
) {
|
|
123
|
-
return EXCEPTION.indexOf(item[PropertyKey.variable]) !== -1
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return false
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { forEach, isObjectNotArray, type Item } from '@dxtmisha/functional-basic'
|
|
4
|
-
|
|
5
|
-
import { PropertiesToAbstract } from './PropertiesToAbstract'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type PropertyItem,
|
|
9
|
-
type PropertyItemsItem,
|
|
10
|
-
PropertyKey,
|
|
11
|
-
type PropertyList,
|
|
12
|
-
PropertyType
|
|
13
|
-
} from '../../../types/propertyTypes'
|
|
14
|
-
|
|
15
|
-
import { sortList } from '../../../media/properties/listSort'
|
|
16
|
-
|
|
17
|
-
type PropertiesSortItem = {
|
|
18
|
-
name: string
|
|
19
|
-
item: PropertyItem
|
|
20
|
-
order: number
|
|
21
|
-
}
|
|
22
|
-
type PropertiesSortList = PropertiesSortItem[]
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Class for sorting properties.
|
|
26
|
-
*
|
|
27
|
-
* Класс для сортировки свойств.
|
|
28
|
-
*/
|
|
29
|
-
export class PropertiesToSort extends PropertiesToAbstract {
|
|
30
|
-
protected readonly FILE_CACHE = '048-sort'
|
|
31
|
-
|
|
32
|
-
protected init(): void {
|
|
33
|
-
this.read()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Sorts all records.
|
|
38
|
-
*
|
|
39
|
-
* Сортирует все записи.
|
|
40
|
-
* @param properties an array that needs to be transformed/
|
|
41
|
-
* массив, который нужно преобразовать
|
|
42
|
-
*/
|
|
43
|
-
private read(properties?: PropertyItemsItem): PropertyList {
|
|
44
|
-
const data: PropertiesSortList = []
|
|
45
|
-
|
|
46
|
-
this.items.eachMainOnly((property) => {
|
|
47
|
-
const {
|
|
48
|
-
name,
|
|
49
|
-
value,
|
|
50
|
-
item
|
|
51
|
-
} = property
|
|
52
|
-
const sort = this.getKeys(item)
|
|
53
|
-
|
|
54
|
-
if (isObjectNotArray(value)) {
|
|
55
|
-
item.value = this.read(property)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
item[PropertyKey.sort] = sort.index
|
|
59
|
-
data.push({
|
|
60
|
-
name,
|
|
61
|
-
item,
|
|
62
|
-
order: sort.value
|
|
63
|
-
})
|
|
64
|
-
}, properties)
|
|
65
|
-
|
|
66
|
-
return this.join(data)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Getting the category name of an element.
|
|
71
|
-
*
|
|
72
|
-
* Получение названия категории у элемента.
|
|
73
|
-
* @param item current element/ текущий элемент
|
|
74
|
-
*/
|
|
75
|
-
private getCategoryName(item: PropertyItem): string {
|
|
76
|
-
return `category-${item?.[PropertyKey.category]}`
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Getting data about sorting by object.
|
|
81
|
-
*
|
|
82
|
-
* Получение данных о сортировке по объекту.
|
|
83
|
-
* @param item current element/ текущий элемент
|
|
84
|
-
*/
|
|
85
|
-
private getKeys(item: PropertyItem): Item<number> {
|
|
86
|
-
const category = this.getCategoryName(item)
|
|
87
|
-
const variable = item?.[PropertyKey.variable]
|
|
88
|
-
|
|
89
|
-
const sortIndex = sortList.findIndex(
|
|
90
|
-
({ index }) => index === category || index === variable
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
if (sortIndex !== -1) {
|
|
94
|
-
const sort = sortList[sortIndex]
|
|
95
|
-
if (sort) {
|
|
96
|
-
const order = sort.value.findIndex(names => names.indexOf(item?.[PropertyKey.name] ?? '') !== -1)
|
|
97
|
-
let value = (sortIndex + 1) * 1_000_000
|
|
98
|
-
|
|
99
|
-
if (order !== -1) {
|
|
100
|
-
const key = sort.value[order]?.findIndex(name => name === item?.[PropertyKey.name]) ?? -1
|
|
101
|
-
|
|
102
|
-
value += order * 1_000
|
|
103
|
-
|
|
104
|
-
if (key !== -1) {
|
|
105
|
-
value += key
|
|
106
|
-
} else {
|
|
107
|
-
value += 999
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
value += 999_999
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
index: `${sort.index}${order > 0 ? `@${order}` : ''}`,
|
|
115
|
-
value
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
index: PropertyType.other,
|
|
122
|
-
value: 99_999_999
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Merging records into a list.
|
|
128
|
-
*
|
|
129
|
-
* Соединения записи в список.
|
|
130
|
-
* @param data given for connection/ данный для соединения
|
|
131
|
-
*/
|
|
132
|
-
private join(data: PropertiesSortList): PropertyList {
|
|
133
|
-
const properties: PropertyList = {}
|
|
134
|
-
|
|
135
|
-
data.sort((a, b) => a.order - b.order)
|
|
136
|
-
|
|
137
|
-
forEach(data, ({
|
|
138
|
-
name,
|
|
139
|
-
item
|
|
140
|
-
}) => {
|
|
141
|
-
properties[name] = item
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
return properties
|
|
145
|
-
}
|
|
146
|
-
}
|