@gravity-ui/page-constructor 3.4.0 → 3.5.0-alpha.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.
Files changed (270) hide show
  1. package/CHANGELOG.md +0 -27
  2. package/README.md +0 -2
  3. package/build/cjs/blocks/Banner/schema.d.ts +21 -63
  4. package/build/cjs/blocks/CardLayout/schema.d.ts +4 -10
  5. package/build/cjs/blocks/Companies/schema.d.ts +2 -5
  6. package/build/cjs/blocks/ContentLayout/ContentLayout.js +2 -3
  7. package/build/cjs/blocks/ContentLayout/schema.d.ts +61 -107
  8. package/build/cjs/blocks/ContentLayout/schema.js +18 -23
  9. package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +4 -31
  10. package/build/cjs/blocks/ExtendedFeatures/schema.js +3 -2
  11. package/build/cjs/blocks/FilterBlock/schema.d.ts +5 -13
  12. package/build/cjs/blocks/FilterBlock/schema.js +2 -13
  13. package/build/cjs/blocks/Header/Header.css +7 -6
  14. package/build/cjs/blocks/Header/schema.d.ts +36 -92
  15. package/build/cjs/blocks/Header/schema.js +0 -1
  16. package/build/cjs/blocks/HeaderSlider/schema.d.ts +53 -48
  17. package/build/cjs/blocks/HeaderSlider/schema.js +1 -3
  18. package/build/cjs/blocks/Icons/schema.d.ts +1 -3
  19. package/build/cjs/blocks/Icons/schema.js +1 -2
  20. package/build/cjs/blocks/Info/schema.d.ts +8 -19
  21. package/build/cjs/blocks/Map/schema.d.ts +6 -17
  22. package/build/cjs/blocks/Media/schema.d.ts +152 -204
  23. package/build/cjs/blocks/Media/schema.js +1 -1
  24. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +8 -22
  25. package/build/cjs/blocks/PromoFeaturesBlock/schema.js +0 -1
  26. package/build/cjs/blocks/Questions/schema.d.ts +3 -7
  27. package/build/cjs/blocks/Slider/schema.d.ts +18 -13
  28. package/build/cjs/blocks/Slider/schema.js +5 -4
  29. package/build/cjs/blocks/Table/schema.d.ts +2 -5
  30. package/build/cjs/blocks/Table/schema.js +2 -12
  31. package/build/cjs/blocks/Tabs/schema.d.ts +16 -43
  32. package/build/cjs/components/BlockBase/BlockBase.js +2 -2
  33. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +1 -1
  34. package/build/cjs/components/Image/schema.d.ts +0 -1
  35. package/build/cjs/components/Image/schema.js +2 -3
  36. package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +1 -1
  37. package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +1 -1
  38. package/build/cjs/customization/BlockDecoration.d.ts +1 -1
  39. package/build/cjs/customization/BlockDecoration.js +6 -5
  40. package/build/cjs/editor/{components → Components}/AddBlock/AddBlock.css +1 -1
  41. package/build/cjs/editor/Components/AddBlock/AddBlock.d.ts +7 -0
  42. package/build/cjs/editor/{components → Components}/AddBlock/AddBlock.js +2 -2
  43. package/build/cjs/editor/Components/EditBlock/EditBlock.d.ts +4 -0
  44. package/build/cjs/editor/Components/EditBlock/EditBlock.js +32 -0
  45. package/build/cjs/editor/Containers/Editor.d.ts +2 -0
  46. package/build/cjs/editor/Containers/Editor.js +24 -0
  47. package/build/cjs/editor/index.d.ts +1 -1
  48. package/build/cjs/editor/index.js +1 -1
  49. package/build/cjs/editor/store/index.d.ts +11 -10
  50. package/build/cjs/editor/store/index.js +15 -66
  51. package/build/cjs/editor/store/reducer.d.ts +9 -24
  52. package/build/cjs/editor/store/reducer.js +31 -17
  53. package/build/cjs/editor/store/utils.d.ts +0 -1
  54. package/build/cjs/editor/store/utils.js +1 -3
  55. package/build/cjs/editor/types/index.d.ts +9 -15
  56. package/build/cjs/editor/types/index.js +0 -6
  57. package/build/cjs/editor/utils/index.d.ts +3 -4
  58. package/build/cjs/editor/utils/index.js +4 -6
  59. package/build/cjs/grid/Col/Col.d.ts +1 -1
  60. package/build/cjs/models/constructor-items/blocks.d.ts +8 -13
  61. package/build/cjs/models/constructor.d.ts +2 -2
  62. package/build/cjs/models/customization.d.ts +8 -3
  63. package/build/cjs/models/navigation.d.ts +0 -1
  64. package/build/cjs/navigation/components/Header/Header.css +0 -2
  65. package/build/cjs/navigation/components/Header/Header.js +4 -15
  66. package/build/cjs/navigation/schema.d.ts +0 -1
  67. package/build/cjs/schema/index.d.ts +228 -9
  68. package/build/cjs/schema/index.js +46 -8
  69. package/build/cjs/schema/validators/common.d.ts +27 -71
  70. package/build/cjs/schema/validators/common.js +17 -50
  71. package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +5 -12
  72. package/build/cjs/sub-blocks/BasicCard/schema.d.ts +3 -8
  73. package/build/cjs/sub-blocks/Content/schema.d.ts +6 -14
  74. package/build/cjs/sub-blocks/Content/schema.js +1 -9
  75. package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +9 -23
  76. package/build/cjs/sub-blocks/MediaCard/schema.d.ts +6 -16
  77. package/build/cjs/sub-blocks/PriceDetailed/schema.d.ts +0 -1
  78. package/build/cjs/sub-blocks/PriceDetailed/schema.js +1 -5
  79. package/build/cjs/sub-blocks/Quote/schema.d.ts +2 -6
  80. package/build/cjs/text-transform/utils.js +6 -1
  81. package/build/esm/blocks/Banner/schema.d.ts +21 -63
  82. package/build/esm/blocks/CardLayout/schema.d.ts +4 -10
  83. package/build/esm/blocks/Companies/schema.d.ts +2 -5
  84. package/build/esm/blocks/ContentLayout/ContentLayout.js +2 -3
  85. package/build/esm/blocks/ContentLayout/schema.d.ts +61 -107
  86. package/build/esm/blocks/ContentLayout/schema.js +18 -23
  87. package/build/esm/blocks/ExtendedFeatures/schema.d.ts +4 -31
  88. package/build/esm/blocks/ExtendedFeatures/schema.js +4 -3
  89. package/build/esm/blocks/FilterBlock/schema.d.ts +5 -13
  90. package/build/esm/blocks/FilterBlock/schema.js +2 -13
  91. package/build/esm/blocks/Header/Header.css +7 -6
  92. package/build/esm/blocks/Header/schema.d.ts +36 -92
  93. package/build/esm/blocks/Header/schema.js +0 -1
  94. package/build/esm/blocks/HeaderSlider/schema.d.ts +53 -48
  95. package/build/esm/blocks/HeaderSlider/schema.js +1 -2
  96. package/build/esm/blocks/Icons/schema.d.ts +1 -3
  97. package/build/esm/blocks/Icons/schema.js +1 -2
  98. package/build/esm/blocks/Info/schema.d.ts +8 -19
  99. package/build/esm/blocks/Map/schema.d.ts +6 -17
  100. package/build/esm/blocks/Media/schema.d.ts +152 -204
  101. package/build/esm/blocks/Media/schema.js +2 -2
  102. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +8 -22
  103. package/build/esm/blocks/PromoFeaturesBlock/schema.js +0 -1
  104. package/build/esm/blocks/Questions/schema.d.ts +3 -7
  105. package/build/esm/blocks/Slider/schema.d.ts +18 -13
  106. package/build/esm/blocks/Slider/schema.js +5 -4
  107. package/build/esm/blocks/Table/schema.d.ts +2 -5
  108. package/build/esm/blocks/Table/schema.js +2 -12
  109. package/build/esm/blocks/Tabs/schema.d.ts +16 -43
  110. package/build/esm/components/BlockBase/BlockBase.js +2 -2
  111. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +1 -1
  112. package/build/esm/components/Image/schema.d.ts +0 -1
  113. package/build/esm/components/Image/schema.js +2 -3
  114. package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +1 -1
  115. package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +1 -1
  116. package/build/esm/customization/BlockDecoration.d.ts +1 -1
  117. package/build/esm/customization/BlockDecoration.js +6 -6
  118. package/build/esm/editor/{components → Components}/AddBlock/AddBlock.css +1 -1
  119. package/build/esm/editor/Components/AddBlock/AddBlock.d.ts +8 -0
  120. package/build/esm/editor/{components → Components}/AddBlock/AddBlock.js +2 -2
  121. package/build/esm/editor/Components/EditBlock/EditBlock.d.ts +5 -0
  122. package/build/esm/editor/Components/EditBlock/EditBlock.js +30 -0
  123. package/build/esm/editor/Containers/Editor.d.ts +2 -0
  124. package/build/esm/editor/Containers/Editor.js +20 -0
  125. package/build/esm/editor/index.d.ts +1 -1
  126. package/build/esm/editor/index.js +1 -1
  127. package/build/esm/editor/store/index.d.ts +11 -10
  128. package/build/esm/editor/store/index.js +17 -68
  129. package/build/esm/editor/store/reducer.d.ts +9 -24
  130. package/build/esm/editor/store/reducer.js +29 -15
  131. package/build/esm/editor/store/utils.d.ts +0 -1
  132. package/build/esm/editor/store/utils.js +0 -1
  133. package/build/esm/editor/types/index.d.ts +9 -15
  134. package/build/esm/editor/types/index.js +1 -5
  135. package/build/esm/editor/utils/index.d.ts +3 -4
  136. package/build/esm/editor/utils/index.js +3 -4
  137. package/build/esm/grid/Col/Col.d.ts +1 -1
  138. package/build/esm/models/constructor-items/blocks.d.ts +8 -13
  139. package/build/esm/models/constructor.d.ts +2 -2
  140. package/build/esm/models/customization.d.ts +8 -3
  141. package/build/esm/models/navigation.d.ts +0 -1
  142. package/build/esm/navigation/components/Header/Header.css +0 -2
  143. package/build/esm/navigation/components/Header/Header.js +5 -16
  144. package/build/esm/navigation/schema.d.ts +0 -1
  145. package/build/esm/schema/index.d.ts +228 -9
  146. package/build/esm/schema/index.js +42 -4
  147. package/build/esm/schema/validators/common.d.ts +27 -71
  148. package/build/esm/schema/validators/common.js +16 -49
  149. package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +5 -12
  150. package/build/esm/sub-blocks/BasicCard/schema.d.ts +3 -8
  151. package/build/esm/sub-blocks/Content/schema.d.ts +6 -14
  152. package/build/esm/sub-blocks/Content/schema.js +1 -9
  153. package/build/esm/sub-blocks/LayoutItem/schema.d.ts +9 -23
  154. package/build/esm/sub-blocks/MediaCard/schema.d.ts +6 -16
  155. package/build/esm/sub-blocks/PriceDetailed/schema.d.ts +0 -1
  156. package/build/esm/sub-blocks/PriceDetailed/schema.js +1 -5
  157. package/build/esm/sub-blocks/Quote/schema.d.ts +2 -6
  158. package/build/esm/text-transform/utils.js +6 -1
  159. package/package.json +4 -5
  160. package/server/models/constructor-items/blocks.d.ts +8 -13
  161. package/server/models/constructor.d.ts +2 -2
  162. package/server/models/customization.d.ts +8 -3
  163. package/server/models/navigation.d.ts +0 -1
  164. package/server/text-transform/utils.js +6 -1
  165. package/build/cjs/editor/components/AddBlock/AddBlock.d.ts +0 -7
  166. package/build/cjs/editor/components/BlockForm/BlockForm.d.ts +0 -12
  167. package/build/cjs/editor/components/BlockForm/BlockForm.js +0 -33
  168. package/build/cjs/editor/components/ControlPanel/ControlPanel.css +0 -26
  169. package/build/cjs/editor/components/ControlPanel/ControlPanel.d.ts +0 -8
  170. package/build/cjs/editor/components/ControlPanel/ControlPanel.js +0 -24
  171. package/build/cjs/editor/components/ControlPanel/i18n/en.json +0 -3
  172. package/build/cjs/editor/components/ControlPanel/i18n/index.d.ts +0 -2
  173. package/build/cjs/editor/components/ControlPanel/i18n/index.js +0 -8
  174. package/build/cjs/editor/components/ControlPanel/i18n/ru.json +0 -3
  175. package/build/cjs/editor/components/EditBlock/EditBlock.d.ts +0 -13
  176. package/build/cjs/editor/components/EditBlock/EditBlock.js +0 -44
  177. package/build/cjs/editor/components/ErrorBoundary/ErrorBoundary.css +0 -27
  178. package/build/cjs/editor/components/ErrorBoundary/ErrorBoundary.d.ts +0 -13
  179. package/build/cjs/editor/components/ErrorBoundary/ErrorBoundary.js +0 -35
  180. package/build/cjs/editor/components/ErrorBoundary/i18n/en.json +0 -4
  181. package/build/cjs/editor/components/ErrorBoundary/i18n/index.d.ts +0 -2
  182. package/build/cjs/editor/components/ErrorBoundary/i18n/index.js +0 -8
  183. package/build/cjs/editor/components/ErrorBoundary/i18n/ru.json +0 -4
  184. package/build/cjs/editor/components/Layout/Layout.css +0 -36
  185. package/build/cjs/editor/components/Layout/Layout.d.ts +0 -16
  186. package/build/cjs/editor/components/Layout/Layout.js +0 -34
  187. package/build/cjs/editor/components/PagePropsForm/PagePropsForm.d.ts +0 -10
  188. package/build/cjs/editor/components/PagePropsForm/PagePropsForm.js +0 -17
  189. package/build/cjs/editor/containers/Editor/Editor.d.ts +0 -2
  190. package/build/cjs/editor/containers/Editor/Editor.js +0 -40
  191. package/build/cjs/editor/containers/Form/Form.css +0 -94
  192. package/build/cjs/editor/containers/Form/Form.d.ts +0 -11
  193. package/build/cjs/editor/containers/Form/Form.js +0 -47
  194. package/build/cjs/editor/containers/Form/dynamic-form-custom.css +0 -0
  195. package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.css +0 -27
  196. package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.d.ts +0 -19
  197. package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +0 -72
  198. package/build/cjs/editor/dynamic-forms-custom/config.d.ts +0 -2
  199. package/build/cjs/editor/dynamic-forms-custom/config.js +0 -13
  200. package/build/cjs/editor/dynamic-forms-custom/hooks/useOneOf.d.ts +0 -12
  201. package/build/cjs/editor/dynamic-forms-custom/hooks/useOneOf.js +0 -75
  202. package/build/cjs/editor/dynamic-forms-custom/parser/detect.d.ts +0 -9
  203. package/build/cjs/editor/dynamic-forms-custom/parser/detect.js +0 -36
  204. package/build/cjs/editor/dynamic-forms-custom/parser/index.d.ts +0 -28
  205. package/build/cjs/editor/dynamic-forms-custom/parser/index.js +0 -188
  206. package/build/cjs/editor/dynamic-forms-custom/parser/types.d.ts +0 -29
  207. package/build/cjs/editor/dynamic-forms-custom/parser/types.js +0 -2
  208. package/build/cjs/editor/dynamic-forms-custom/parser/views.d.ts +0 -37
  209. package/build/cjs/editor/dynamic-forms-custom/parser/views.js +0 -46
  210. package/build/cjs/editor/hooks/useFormSpec.d.ts +0 -2
  211. package/build/cjs/editor/hooks/useFormSpec.js +0 -13
  212. package/build/cjs/editor/hooks/usePreviousValue.d.ts +0 -1
  213. package/build/cjs/editor/hooks/usePreviousValue.js +0 -11
  214. package/build/cjs/editor/styles/root.css +0 -5
  215. package/build/cjs/schema/constants.d.ts +0 -908
  216. package/build/cjs/schema/constants.js +0 -42
  217. package/build/esm/editor/components/AddBlock/AddBlock.d.ts +0 -8
  218. package/build/esm/editor/components/BlockForm/BlockForm.d.ts +0 -12
  219. package/build/esm/editor/components/BlockForm/BlockForm.js +0 -30
  220. package/build/esm/editor/components/ControlPanel/ControlPanel.css +0 -26
  221. package/build/esm/editor/components/ControlPanel/ControlPanel.d.ts +0 -9
  222. package/build/esm/editor/components/ControlPanel/ControlPanel.js +0 -22
  223. package/build/esm/editor/components/ControlPanel/i18n/en.json +0 -3
  224. package/build/esm/editor/components/ControlPanel/i18n/index.d.ts +0 -2
  225. package/build/esm/editor/components/ControlPanel/i18n/index.js +0 -5
  226. package/build/esm/editor/components/ControlPanel/i18n/ru.json +0 -3
  227. package/build/esm/editor/components/EditBlock/EditBlock.d.ts +0 -14
  228. package/build/esm/editor/components/EditBlock/EditBlock.js +0 -41
  229. package/build/esm/editor/components/ErrorBoundary/ErrorBoundary.css +0 -27
  230. package/build/esm/editor/components/ErrorBoundary/ErrorBoundary.d.ts +0 -14
  231. package/build/esm/editor/components/ErrorBoundary/ErrorBoundary.js +0 -31
  232. package/build/esm/editor/components/ErrorBoundary/i18n/en.json +0 -4
  233. package/build/esm/editor/components/ErrorBoundary/i18n/index.d.ts +0 -2
  234. package/build/esm/editor/components/ErrorBoundary/i18n/index.js +0 -5
  235. package/build/esm/editor/components/ErrorBoundary/i18n/ru.json +0 -4
  236. package/build/esm/editor/components/Layout/Layout.css +0 -36
  237. package/build/esm/editor/components/Layout/Layout.d.ts +0 -17
  238. package/build/esm/editor/components/Layout/Layout.js +0 -32
  239. package/build/esm/editor/components/PagePropsForm/PagePropsForm.d.ts +0 -10
  240. package/build/esm/editor/components/PagePropsForm/PagePropsForm.js +0 -13
  241. package/build/esm/editor/containers/Editor/Editor.d.ts +0 -2
  242. package/build/esm/editor/containers/Editor/Editor.js +0 -36
  243. package/build/esm/editor/containers/Form/Form.css +0 -94
  244. package/build/esm/editor/containers/Form/Form.d.ts +0 -12
  245. package/build/esm/editor/containers/Form/Form.js +0 -45
  246. package/build/esm/editor/containers/Form/dynamic-form-custom.css +0 -0
  247. package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.css +0 -27
  248. package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.d.ts +0 -20
  249. package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +0 -68
  250. package/build/esm/editor/dynamic-forms-custom/config.d.ts +0 -2
  251. package/build/esm/editor/dynamic-forms-custom/config.js +0 -9
  252. package/build/esm/editor/dynamic-forms-custom/hooks/useOneOf.d.ts +0 -12
  253. package/build/esm/editor/dynamic-forms-custom/hooks/useOneOf.js +0 -69
  254. package/build/esm/editor/dynamic-forms-custom/parser/detect.d.ts +0 -9
  255. package/build/esm/editor/dynamic-forms-custom/parser/detect.js +0 -32
  256. package/build/esm/editor/dynamic-forms-custom/parser/index.d.ts +0 -28
  257. package/build/esm/editor/dynamic-forms-custom/parser/index.js +0 -186
  258. package/build/esm/editor/dynamic-forms-custom/parser/types.d.ts +0 -29
  259. package/build/esm/editor/dynamic-forms-custom/parser/types.js +0 -1
  260. package/build/esm/editor/dynamic-forms-custom/parser/views.d.ts +0 -37
  261. package/build/esm/editor/dynamic-forms-custom/parser/views.js +0 -39
  262. package/build/esm/editor/hooks/useFormSpec.d.ts +0 -2
  263. package/build/esm/editor/hooks/useFormSpec.js +0 -9
  264. package/build/esm/editor/hooks/usePreviousValue.d.ts +0 -1
  265. package/build/esm/editor/hooks/usePreviousValue.js +0 -8
  266. package/build/esm/editor/styles/root.css +0 -5
  267. package/build/esm/schema/constants.d.ts +0 -908
  268. package/build/esm/schema/constants.js +0 -39
  269. /package/build/cjs/editor/{components → Components}/EditBlock/EditBlock.css +0 -0
  270. /package/build/esm/editor/{components → Components}/EditBlock/EditBlock.css +0 -0
@@ -1,45 +0,0 @@
1
- import { __rest } from "tslib";
2
- import React, { Fragment, memo } from 'react';
3
- import { Tabs } from '@gravity-ui/uikit';
4
- import { block, getBlockKey } from '../../../utils';
5
- import { BlockForm } from '../../components/BlockForm/BlockForm';
6
- import { PagePropsForm } from '../../components/PagePropsForm/PagePropsForm';
7
- import './Form.css';
8
- var FormTab;
9
- (function (FormTab) {
10
- FormTab["Blocks"] = "blocks";
11
- FormTab["Page"] = "page";
12
- })(FormTab || (FormTab = {}));
13
- const b = block('editor-form');
14
- const tabsItems = Object.values(FormTab).map((tab) => ({
15
- id: tab,
16
- title: tab,
17
- }));
18
- export const Form = memo(({ content, onChange, activeBlockIndex, onSelect, spec }) => {
19
- const [activeTab, setActiveTab] = React.useState(FormTab.Blocks);
20
- const _a = content || {}, { blocks } = _a, page = __rest(_a, ["blocks"]);
21
- const { blocks: blocksSpec, page: pageSpec } = spec || {};
22
- let form;
23
- switch (activeTab) {
24
- case FormTab.Page: {
25
- form = (React.createElement(PagePropsForm, { spec: pageSpec, data: page, onChange: (data) => {
26
- return onChange(Object.assign(Object.assign({}, content), data));
27
- } }));
28
- break;
29
- }
30
- case FormTab.Blocks: {
31
- form = (React.createElement(Fragment, null, blocks.map((blockData, index) => (React.createElement(BlockForm, { spec: blocksSpec[blockData.type], key: getBlockKey(blockData, index), data: blockData, active: activeBlockIndex === index, onChange: (data) => {
32
- onChange(Object.assign(Object.assign({}, content), { blocks: [
33
- ...blocks.slice(0, index),
34
- data,
35
- ...blocks.slice(index + 1),
36
- ] }));
37
- }, onSelect: () => onSelect(index) })))));
38
- break;
39
- }
40
- }
41
- return (React.createElement("div", { className: b() },
42
- React.createElement(Tabs, { activeTab: activeTab, className: b('tabs'), items: tabsItems, onSelectTab: setActiveTab }),
43
- form));
44
- });
45
- Form.displayName = 'Form';
@@ -1,27 +0,0 @@
1
- .pc-one-of-custom {
2
- display: flex;
3
- flex-direction: column;
4
- }
5
- .pc-one-of-custom:last-child > .df-group-indent {
6
- margin-bottom: 0;
7
- }
8
- .pc-one-of-custom .df-group-indent {
9
- all: unset;
10
- }
11
- .pc-one-of-custom .df-group-indent > .df-use-search {
12
- padding-top: 11px;
13
- padding-left: 20px;
14
- margin-top: 4px;
15
- margin-bottom: 20px;
16
- margin-left: 5px;
17
- border-left: 1px solid var(--yc-color-line-generic-accent);
18
- }
19
- .pc-one-of-custom .df-group-indent > .df-use-search:empty {
20
- display: none;
21
- }
22
- .pc-one-of-custom .df-group-indent > .df-use-search:last-child {
23
- margin-bottom: 0;
24
- }
25
- .pc-one-of-custom .df-group-indent > .df-use-search > .df-simple-vertical-accordeon_view {
26
- margin-top: -10px;
27
- }
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { ObjectIndependentInputProps } from '@gravity-ui/dynamic-forms';
3
- import './OneOfCustom.css';
4
- /**
5
- * Customization of @gravity-ui/dynamic-forms OneOf component
6
- *
7
- * Main differences from original component:
8
- *
9
- * 1. Custom component can detect initial data type by it's json schema passed it __schema property of spec and
10
- * shows according input
11
- *
12
- * 2. Custom component doesn't create additional nested level of data for each OneOf option and doesn't wraps data value, e.g.
13
- *
14
- * custom component: {propertyName: propertyValue}
15
- * original component: {propertyName: {option1: {value: propertyValue}}}
16
- *
17
- * @param {ObjectIndependentInputProps} props - props of original OneOf component
18
- * @returns {React.FC<ObjectIndependentInputProps>}
19
- */
20
- export declare const OneOfCustom: React.FC<ObjectIndependentInputProps>;
@@ -1,68 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { Controller, GroupIndent, SpecTypes, transformArrOut, } from '@gravity-ui/dynamic-forms';
3
- import Ajv from 'ajv';
4
- import _ from 'lodash';
5
- import { block } from '../../../../utils';
6
- import { getSpecTypeDefaultValue, useOneOf } from '../../hooks/useOneOf';
7
- import './OneOfCustom.css';
8
- const b = block('one-of-custom');
9
- const ajv = new Ajv({
10
- $data: true,
11
- strict: false,
12
- strictSchema: false,
13
- strictTypes: false,
14
- strictRequired: false,
15
- });
16
- const getOneOfCustomSpecDefaultType = (spec) => { var _a, _b; return ((_b = (_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b[0]) || Object.keys(spec.properties || {})[0]; };
17
- // dynamic-forms pass {} as default value for required properties of all types
18
- // this function replaces {} with default value accordingly to selected OneOf option spec type
19
- const getControllerDefautValue = (value, valueSpecType) => {
20
- const isDefaultValue = typeof value === 'object' && _.isEmpty(value);
21
- const defaultValue = valueSpecType ? getSpecTypeDefaultValue(valueSpecType) : undefined;
22
- return isDefaultValue ? defaultValue : value;
23
- };
24
- /**
25
- * Customization of @gravity-ui/dynamic-forms OneOf component
26
- *
27
- * Main differences from original component:
28
- *
29
- * 1. Custom component can detect initial data type by it's json schema passed it __schema property of spec and
30
- * shows according input
31
- *
32
- * 2. Custom component doesn't create additional nested level of data for each OneOf option and doesn't wraps data value, e.g.
33
- *
34
- * custom component: {propertyName: propertyValue}
35
- * original component: {propertyName: {option1: {value: propertyValue}}}
36
- *
37
- * @param {ObjectIndependentInputProps} props - props of original OneOf component
38
- * @returns {React.FC<ObjectIndependentInputProps>}
39
- */
40
- export const OneOfCustom = (props) => {
41
- var _a;
42
- const { spec, input, name } = props;
43
- const { properties } = spec;
44
- //getting oneOf option type from initial value
45
- const valueType = useMemo(() => {
46
- var _a;
47
- return (properties &&
48
- ((_a = Object.keys(properties)) === null || _a === void 0 ? void 0 : _a.find((key) => {
49
- const fieldSchema = (properties === null || properties === void 0 ? void 0 : properties[key]).__schema;
50
- return fieldSchema && ajv.validate(fieldSchema, transformArrOut(input.value));
51
- }))) ||
52
- getOneOfCustomSpecDefaultType(spec);
53
- },
54
- // eslint-disable-next-line react-hooks/exhaustive-deps
55
- []);
56
- const { oneOfValue, specProperties, toggler } = useOneOf({
57
- props: Object.assign(Object.assign({}, props), { input: Object.assign(Object.assign({}, input), { value: valueType ? { [valueType]: input.value } : input.value }) }),
58
- });
59
- const parentOnChange = React.useCallback((_childName, childValue, childErrors) => {
60
- input.onChange(childValue, childErrors);
61
- }, [input]);
62
- const parentOnUnmount = React.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input]);
63
- const valueSpecType = ((_a = specProperties[oneOfValue]) === null || _a === void 0 ? void 0 : _a.type) || SpecTypes.Object;
64
- return (React.createElement("div", { className: b() },
65
- React.createElement("div", null, toggler),
66
- specProperties[oneOfValue] && (React.createElement(GroupIndent, null,
67
- React.createElement(Controller, { value: getControllerDefautValue(input.value, valueSpecType), name: name, spec: specProperties[oneOfValue], parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })))));
68
- };
@@ -1,2 +0,0 @@
1
- import { DynamicFormConfig } from '@gravity-ui/dynamic-forms';
2
- export declare const dynamicConfig: DynamicFormConfig;
@@ -1,9 +0,0 @@
1
- import { dynamicConfig as libConfig } from '@gravity-ui/dynamic-forms';
2
- import _ from 'lodash';
3
- import { OneOfCustom } from './components/OneOfCustom/OneOfCustom';
4
- const getDynamicConfig = () => {
5
- const dynamicConfig = _.cloneDeep(libConfig);
6
- dynamicConfig.object.inputs['oneof_custom'] = { Component: OneOfCustom, independent: true };
7
- return dynamicConfig;
8
- };
9
- export const dynamicConfig = getDynamicConfig();
@@ -1,12 +0,0 @@
1
- import { ObjectIndependentInputProps, Spec, SpecTypes } from '@gravity-ui/dynamic-forms';
2
- export interface UseOneOfParams {
3
- props: ObjectIndependentInputProps;
4
- onTogglerChange?: (value: string) => void;
5
- }
6
- export declare const getSpecTypeDefaultValue: (type: SpecTypes) => {} | undefined;
7
- export declare const useOneOf: ({ props, onTogglerChange }: UseOneOfParams) => {
8
- oneOfValue: string;
9
- specProperties: Record<string, Spec>;
10
- toggler: JSX.Element;
11
- togglerInput: JSX.Element;
12
- };
@@ -1,69 +0,0 @@
1
- import React from 'react';
2
- import { SpecTypes, } from '@gravity-ui/dynamic-forms';
3
- import { RadioButton, Select } from '@gravity-ui/uikit';
4
- import _ from 'lodash';
5
- const MAX_TAB_TITLE_LENGTH = 20;
6
- export const getSpecTypeDefaultValue = (type) => {
7
- switch (type) {
8
- case SpecTypes.Array:
9
- return [];
10
- case SpecTypes.Boolean:
11
- case SpecTypes.Number:
12
- case SpecTypes.String:
13
- return undefined;
14
- default:
15
- return {};
16
- }
17
- };
18
- export const useOneOf = ({ props, onTogglerChange }) => {
19
- const { name, input, spec, Layout } = props;
20
- const { order, disabled, oneOfParams } = spec.viewSpec;
21
- const specProperties = React.useMemo(() => (_.isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
22
- const [oneOfValue, setOneOfValue] = React.useState(() => {
23
- let valueKeys;
24
- if (_.isObjectLike(input.value)) {
25
- const keys = Object.keys(input.value);
26
- if (keys.length) {
27
- valueKeys = keys;
28
- }
29
- }
30
- return (valueKeys || order || Object.keys(specProperties))[0];
31
- });
32
- const onOneOfChange = React.useCallback(([newValue]) => {
33
- var _a;
34
- if (newValue !== oneOfValue) {
35
- const specType = ((_a = specProperties[newValue]) === null || _a === void 0 ? void 0 : _a.type) || SpecTypes.Object;
36
- input.onChange(getSpecTypeDefaultValue(specType));
37
- setOneOfValue(newValue);
38
- onTogglerChange === null || onTogglerChange === void 0 ? void 0 : onTogglerChange(newValue);
39
- }
40
- }, [setOneOfValue, input, oneOfValue, specProperties, onTogglerChange]);
41
- const options = React.useMemo(() => (order || Object.keys(specProperties)).map((value) => {
42
- var _a, _b;
43
- const title = ((_a = spec.description) === null || _a === void 0 ? void 0 : _a[value]) ||
44
- ((_b = specProperties[value]) === null || _b === void 0 ? void 0 : _b.viewSpec.layoutTitle) ||
45
- value ||
46
- '';
47
- return {
48
- value,
49
- title,
50
- content: title,
51
- };
52
- }), [spec.description, order, specProperties]);
53
- const togglerInput = React.useMemo(() => {
54
- if ((oneOfParams === null || oneOfParams === void 0 ? void 0 : oneOfParams.toggler) !== 'radio' &&
55
- ((oneOfParams === null || oneOfParams === void 0 ? void 0 : oneOfParams.toggler) === 'select' ||
56
- options.length > 3 ||
57
- _.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH))) {
58
- return (React.createElement(Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: disabled, filterable: options.length > 7, qa: name }));
59
- }
60
- return (React.createElement(RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: disabled, qa: name }, options.map(({ value, title }) => (React.createElement(RadioButton.Option, { key: value, value: value }, title)))));
61
- }, [options, oneOfValue, onOneOfChange, name, oneOfParams === null || oneOfParams === void 0 ? void 0 : oneOfParams.toggler, disabled]);
62
- const toggler = React.useMemo(() => {
63
- if (Layout) {
64
- return React.createElement(Layout, Object.assign({}, props), togglerInput);
65
- }
66
- return togglerInput;
67
- }, [Layout, togglerInput, props]);
68
- return { oneOfValue, specProperties, toggler, togglerInput };
69
- };
@@ -1,9 +0,0 @@
1
- import { Schema } from '../../../schema';
2
- export declare enum ParserType {
3
- Object = "object",
4
- Array = "array",
5
- Children = "children",
6
- OneOf = "oneOf",
7
- Primitive = "primitive"
8
- }
9
- export declare const detectParserType: (data: Schema) => ParserType;
@@ -1,32 +0,0 @@
1
- import { SpecTypes } from '@gravity-ui/dynamic-forms';
2
- export var ParserType;
3
- (function (ParserType) {
4
- ParserType["Object"] = "object";
5
- ParserType["Array"] = "array";
6
- ParserType["Children"] = "children";
7
- ParserType["OneOf"] = "oneOf";
8
- ParserType["Primitive"] = "primitive";
9
- })(ParserType || (ParserType = {}));
10
- const isOneOf = (data) => 'oneOf' in data;
11
- const isObject = (data) => 'properties' in data;
12
- const isArray = (data) => 'type' in data && data.type === SpecTypes.Array;
13
- const isChildren = (data) => 'type' in data &&
14
- data.type === SpecTypes.Array &&
15
- 'items' in data &&
16
- typeof data.items !== 'undefined' &&
17
- '$ref' in data.items;
18
- //detector applying order matters!
19
- const ParserTypeDetectors = [
20
- { type: ParserType.OneOf, detector: isOneOf },
21
- { type: ParserType.Children, detector: isChildren },
22
- { type: ParserType.Object, detector: isObject },
23
- { type: ParserType.Array, detector: isArray },
24
- ];
25
- export const detectParserType = (data) => {
26
- for (const { type, detector } of ParserTypeDetectors) {
27
- if (detector(data)) {
28
- return type;
29
- }
30
- }
31
- return ParserType.Primitive;
32
- };
@@ -1,28 +0,0 @@
1
- import { Schema } from '../../../schema';
2
- import { FormSpecs } from './types';
3
- declare class FormSpecParser {
4
- private schema;
5
- private definitions;
6
- /**
7
- * Transforms page-constructor json schema into dynamic-forms specs for each block
8
- *
9
- * @param schema {Schema} - page-constructor json schema
10
- * @returns {FormSpecs} - object containig dynamic-forms specs for each constructor block
11
- */
12
- parse(schema: Schema): FormSpecs;
13
- private getChildrenSpec;
14
- private getRequiredProperties;
15
- private childrenParser;
16
- private oneOfParser;
17
- private arrayParser;
18
- private objectParser;
19
- private primitiveParser;
20
- private schemaParserMap;
21
- private parseSchemaProperty;
22
- private getBlocksSpec;
23
- private getPageSpec;
24
- private getFormSpec;
25
- private init;
26
- }
27
- declare const _default: FormSpecParser;
28
- export default _default;
@@ -1,186 +0,0 @@
1
- import { __rest } from "tslib";
2
- /* eslint-disable no-param-reassign */
3
- /* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
4
- import { SpecTypes } from '@gravity-ui/dynamic-forms';
5
- import { BlockType } from '../../../models';
6
- import { ParserType, detectParserType } from './detect';
7
- import { getArrayViewSpec, getObjectViewSpec, getOneOfViewSpec, getPrimitiveViewSpec } from './views';
8
- class FormSpecParser {
9
- constructor() {
10
- this.schema = {};
11
- this.definitions = {};
12
- this.getChildrenSpec = (data) => {
13
- var _a, _b, _c;
14
- const childrenType = (_c = (_b = (_a = data.items) === null || _a === void 0 ? void 0 : _a.$ref) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop();
15
- return this.definitions[childrenType];
16
- };
17
- this.getRequiredProperties = (data) => Array.isArray(data.required) ? data.required : [];
18
- this.childrenParser = ({ data, name, required }) => {
19
- const childSpec = this.getChildrenSpec(data);
20
- const properties = childSpec &&
21
- Object.entries(childSpec).reduce((parsedChildSpecProperties, [childName, childSchema]) => {
22
- const childRequiredProperties = this.getRequiredProperties(childSchema);
23
- const childProperies = childSchema.properties &&
24
- Object.entries(childSchema.properties).reduce((parsedChildProperties, [childPropertyName, childPropertyData]) => {
25
- parsedChildProperties[childPropertyName] = this.parseSchemaProperty({
26
- data: childPropertyData,
27
- name: childPropertyName,
28
- required: childRequiredProperties.includes(childPropertyName),
29
- });
30
- return parsedChildProperties;
31
- }, {});
32
- const childJsonSchema = Object.assign(Object.assign({}, childSchema), { properties: Object.assign(Object.assign({}, childSchema.properties), { type: {
33
- type: SpecTypes.String,
34
- enum: [childName],
35
- } }) });
36
- parsedChildSpecProperties[childName] = {
37
- type: SpecTypes.Array,
38
- items: Object.assign(Object.assign({}, childSchema), { type: SpecTypes.Object, properties: Object.assign(Object.assign({}, childProperies), { type: {
39
- type: SpecTypes.String,
40
- defaultValue: childName,
41
- viewSpec: {
42
- type: 'hidden',
43
- },
44
- } }), viewSpec: childProperies &&
45
- getObjectViewSpec({
46
- properties: childProperies,
47
- layoutTitle: childName,
48
- }), __schema: childJsonSchema }),
49
- required: false,
50
- viewSpec: getArrayViewSpec({ layoutTitle: childName }),
51
- __schema: {
52
- type: SpecTypes.Array,
53
- items: childJsonSchema,
54
- },
55
- };
56
- return parsedChildSpecProperties;
57
- }, {});
58
- return {
59
- type: SpecTypes.Object,
60
- properties,
61
- viewSpec: {
62
- type: 'oneof_custom',
63
- layout: 'row',
64
- layoutTitle: name,
65
- oneOfParams: {
66
- toggler: 'select',
67
- },
68
- },
69
- required,
70
- };
71
- };
72
- this.oneOfParser = ({ data, name, required }) => {
73
- const requiredProperties = this.getRequiredProperties(data);
74
- const properties = data.oneOf &&
75
- data.oneOf.reduce((result, propertyData, index) => {
76
- const propertyName = (propertyData === null || propertyData === void 0 ? void 0 : propertyData.optionName)
77
- ? propertyData === null || propertyData === void 0 ? void 0 : propertyData.optionName
78
- : `${name}_${index}`;
79
- result[propertyName] = this.parseSchemaProperty({
80
- data: propertyData,
81
- name: propertyName,
82
- required: requiredProperties.includes(propertyName),
83
- });
84
- return result;
85
- }, {});
86
- return {
87
- type: SpecTypes.Object,
88
- properties,
89
- required,
90
- viewSpec: getOneOfViewSpec({ layoutTitle: name }),
91
- };
92
- };
93
- this.arrayParser = ({ data, name }) => {
94
- const items = data.items && this.parseSchemaProperty({ data: data.items, name });
95
- return Object.assign(Object.assign({}, data), { type: SpecTypes.Array, items, viewSpec: getArrayViewSpec({ layoutTitle: name }) });
96
- };
97
- this.objectParser = ({ data, name, required }) => {
98
- const requiredProperties = this.getRequiredProperties(data);
99
- const properties = data.properties &&
100
- Object.entries(data.properties).reduce((result, [propertyName, propertyData]) => {
101
- result[propertyName] = this.parseSchemaProperty({
102
- data: propertyData,
103
- name: propertyName,
104
- required: requiredProperties.includes(propertyName),
105
- });
106
- return result;
107
- }, {});
108
- return Object.assign(Object.assign({}, data), { type: SpecTypes.Object, properties, viewSpec: getObjectViewSpec({ properties, layoutTitle: name }), required });
109
- };
110
- this.primitiveParser = ({ data, name, required }) => {
111
- return Object.assign(Object.assign({}, data), { type: data.type, required, defaultValue: data.default, viewSpec: getPrimitiveViewSpec({ layoutTitle: name, data }), validator: 'base' });
112
- };
113
- //eslint-disable-next-line @typescript-eslint/member-ordering
114
- this.schemaParserMap = {
115
- [ParserType.Object]: this.objectParser,
116
- [ParserType.Array]: this.arrayParser,
117
- [ParserType.Primitive]: this.primitiveParser,
118
- [ParserType.OneOf]: this.oneOfParser,
119
- [ParserType.Children]: this.childrenParser,
120
- };
121
- }
122
- /**
123
- * Transforms page-constructor json schema into dynamic-forms specs for each block
124
- *
125
- * @param schema {Schema} - page-constructor json schema
126
- * @returns {FormSpecs} - object containig dynamic-forms specs for each constructor block
127
- */
128
- parse(schema) {
129
- this.init(schema);
130
- return this.getFormSpec();
131
- }
132
- parseSchemaProperty({ data, name, required }) {
133
- const parserType = detectParserType(data);
134
- const parser = this.schemaParserMap[parserType];
135
- return Object.assign(Object.assign({}, parser({ data, name, required })), {
136
- //save json schema from constructor to compare with incoming intial data inside oneOf form fields
137
- __schema: data });
138
- }
139
- getBlocksSpec() {
140
- const blocks = this.definitions.children;
141
- return Object.values(BlockType).reduce((result, blockName) => {
142
- result[blockName] = this.parseSchemaProperty({
143
- name: blockName,
144
- data: Object.assign({}, blocks[blockName]),
145
- required: true,
146
- });
147
- return result;
148
- }, {});
149
- }
150
- getPageSpec() {
151
- var _a;
152
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
153
- const _b = ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.properties) || {}, { blocks } = _b, pageSchema = __rest(_b, ["blocks"]);
154
- const requiredProperties = this.getRequiredProperties(this.schema);
155
- const properties = Object.entries(pageSchema).reduce((result, [propertyName, propertyData]) => {
156
- result[propertyName] = this.parseSchemaProperty({
157
- name: propertyName,
158
- data: propertyData,
159
- required: requiredProperties.includes(propertyName),
160
- });
161
- return result;
162
- }, {});
163
- return {
164
- type: SpecTypes.Object,
165
- properties,
166
- viewSpec: getObjectViewSpec({ properties, layout: 'section' }),
167
- required: true,
168
- };
169
- }
170
- getFormSpec() {
171
- return {
172
- blocks: this.getBlocksSpec(),
173
- page: this.getPageSpec(),
174
- };
175
- }
176
- init(schema) {
177
- this.schema = schema;
178
- if (schema.definitions) {
179
- this.definitions = Object.entries(schema.definitions).reduce((result, [childType, childSpec]) => {
180
- result[childType] = childSpec === null || childSpec === void 0 ? void 0 : childSpec.selectCases;
181
- return result;
182
- }, {});
183
- }
184
- }
185
- }
186
- export default new FormSpecParser();
@@ -1,29 +0,0 @@
1
- import { Spec as DynamicFormSpec, ObjectSpec } from '@gravity-ui/dynamic-forms';
2
- import { BlockType } from '../../../models';
3
- import { Schema } from '../../../schema';
4
- export type OneOfSpec = {
5
- oneOf: DynamicFormSpec[];
6
- viewSpec: ObjectSpec['viewSpec'];
7
- };
8
- export type CustomObjectSpec = Omit<ObjectSpec, 'properties'> & {
9
- properties: Record<string, CustomSpec>;
10
- };
11
- export interface SpecCustomProps {
12
- disabled?: boolean;
13
- inputType?: string;
14
- __schema?: Schema;
15
- }
16
- export type Spec = Exclude<DynamicFormSpec, 'ObjectSpec'> | CustomObjectSpec | OneOfSpec;
17
- export type CustomSpec = Spec & SpecCustomProps;
18
- export type BlocksSpec = Record<BlockType, CustomSpec>;
19
- export type PageSpec = CustomSpec;
20
- export interface FormSpecs {
21
- blocks: BlocksSpec;
22
- page: PageSpec;
23
- }
24
- export interface SchemaParserParams {
25
- data: Schema;
26
- name: string;
27
- required?: Schema['required'];
28
- }
29
- export type SchemaParser = (params: SchemaParserParams) => CustomSpec;
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- import { Schema } from '../../../schema';
2
- import { CustomObjectSpec, CustomSpec } from './types';
3
- interface BaseParams {
4
- layoutTitle?: string;
5
- }
6
- interface GetObjectViewSpecParams extends BaseParams, Partial<Extract<CustomSpec, CustomObjectSpec>> {
7
- layout?: string;
8
- }
9
- type GetPrimitiveViewSpecParams = BaseParams & Schema;
10
- export declare const getOneOfViewSpec: ({ layoutTitle }: BaseParams) => {
11
- type: string;
12
- layout: string;
13
- layoutTitle: string | undefined;
14
- oneOfParams: {
15
- toggler: "select";
16
- };
17
- };
18
- export declare const getObjectViewSpec: ({ properties, disabled, layoutTitle, layout, }: GetObjectViewSpecParams) => {
19
- layoutTitle: string | undefined;
20
- type: string;
21
- layout: string;
22
- order: string[] | undefined;
23
- disabled: boolean | undefined;
24
- };
25
- export declare const getArrayViewSpec: ({ layoutTitle }: BaseParams) => {
26
- layoutTitle: string | undefined;
27
- type: string;
28
- layout: string;
29
- layoutOpen: boolean;
30
- itemLabel: string;
31
- };
32
- export declare const getPrimitiveViewSpec: ({ layoutTitle, ...data }: GetPrimitiveViewSpecParams) => {
33
- layout: string;
34
- type: any;
35
- layoutTitle: string | undefined;
36
- };
37
- export {};
@@ -1,39 +0,0 @@
1
- import { __rest } from "tslib";
2
- export const getOneOfViewSpec = ({ layoutTitle }) => {
3
- return {
4
- type: 'oneof_custom',
5
- layout: 'row',
6
- layoutTitle,
7
- oneOfParams: {
8
- toggler: 'select',
9
- },
10
- };
11
- };
12
- export const getObjectViewSpec = ({ properties, disabled, layoutTitle, layout = 'accordeon', }) => {
13
- return {
14
- layoutTitle,
15
- type: 'base',
16
- layout,
17
- order: properties && Object.keys(properties).sort(),
18
- disabled,
19
- };
20
- };
21
- export const getArrayViewSpec = ({ layoutTitle }) => ({
22
- layoutTitle,
23
- type: 'base',
24
- layout: 'accordeon',
25
- layoutOpen: true,
26
- itemLabel: 'Add Item',
27
- });
28
- export const getPrimitiveViewSpec = (_a) => {
29
- var { layoutTitle } = _a, data = __rest(_a, ["layoutTitle"]);
30
- let type = (data === null || data === void 0 ? void 0 : data.inputType) || 'base';
31
- if (data && 'enum' in data && data.enum) {
32
- type = 'select';
33
- }
34
- return {
35
- layout: 'row',
36
- type,
37
- layoutTitle,
38
- };
39
- };
@@ -1,2 +0,0 @@
1
- import { SchemaCustomConfig } from '../../schema';
2
- export default function useFormSpec(customSchema?: SchemaCustomConfig): import("../dynamic-forms-custom/parser/types").FormSpecs;
@@ -1,9 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { generateDefaultSchema } from '../../schema';
3
- import formSpecParser from '../dynamic-forms-custom/parser';
4
- export default function useFormSpec(customSchema) {
5
- return useMemo(() => {
6
- const schema = generateDefaultSchema(customSchema);
7
- return formSpecParser.parse(schema);
8
- }, [customSchema]);
9
- }
@@ -1 +0,0 @@
1
- export default function usePreviousValue<T>(value: T): T | undefined;
@@ -1,8 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- export default function usePreviousValue(value) {
3
- const ref = useRef();
4
- useEffect(() => {
5
- ref.current = value;
6
- }, [value]);
7
- return ref.current;
8
- }