@qoretechnologies/reqraft 0.10.55-pr.124.g43fa138 → 0.10.55
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/.claude/CLAUDE.md +25 -0
- package/.tasks/INDEX.md +1 -0
- package/.tasks/STORY_NETWORK_ISOLATION.md +98 -0
- package/README.md +1 -1
- package/design/FORM_ENGINE_COMPACT.md +34 -0
- package/design/FORM_ENGINE_EXPRESSIONS.md +110 -0
- package/design/FORM_ENGINE_FIELD_MIGRATION.md +155 -1
- package/design/IDE_INTEGRATION.md +13 -0
- package/design/RENDER_EXPRESSION_TRANSPORT.md +76 -10
- package/design/SELECT_DIALOG_FLOOR.md +86 -0
- package/design/SMART_EDITOR_UX.md +21 -0
- package/design/UNAVAILABLE_ALLOWED_VALUES.md +226 -0
- package/dist/components/composer/Composer.d.ts +8 -3
- package/dist/components/composer/Composer.d.ts.map +1 -1
- package/dist/components/composer/Composer.js.map +1 -1
- package/dist/components/dpqlEditor/DpqlEditor.d.ts.map +1 -1
- package/dist/components/dpqlEditor/DpqlEditor.js +3 -3
- package/dist/components/dpqlEditor/DpqlEditor.js.map +1 -1
- package/dist/components/dpqlEditor/dpqlHelpers.d.ts +6 -0
- package/dist/components/dpqlEditor/dpqlHelpers.d.ts.map +1 -1
- package/dist/components/dpqlEditor/dpqlHelpers.js +21 -2
- package/dist/components/dpqlEditor/dpqlHelpers.js.map +1 -1
- package/dist/components/dpqlEditor/dpqlProbe.d.ts +37 -0
- package/dist/components/dpqlEditor/dpqlProbe.d.ts.map +1 -0
- package/dist/components/dpqlEditor/dpqlProbe.js +203 -0
- package/dist/components/dpqlEditor/dpqlProbe.js.map +1 -0
- package/dist/components/dpqlEditor/dpqlTags.d.ts +8 -0
- package/dist/components/dpqlEditor/dpqlTags.d.ts.map +1 -1
- package/dist/components/dpqlEditor/dpqlTags.js +5 -1
- package/dist/components/dpqlEditor/dpqlTags.js.map +1 -1
- package/dist/components/dpqlEditor/index.d.ts +4 -0
- package/dist/components/dpqlEditor/index.d.ts.map +1 -1
- package/dist/components/dpqlEditor/index.js +5 -1
- package/dist/components/dpqlEditor/index.js.map +1 -1
- package/dist/components/dpqlEditor/types.d.ts +42 -2
- package/dist/components/dpqlEditor/types.d.ts.map +1 -1
- package/dist/components/dpqlEditor/types.js +0 -4
- package/dist/components/dpqlEditor/types.js.map +1 -1
- package/dist/components/dpqlEditor/useDpqlProbe.d.ts +4 -0
- package/dist/components/dpqlEditor/useDpqlProbe.d.ts.map +1 -0
- package/dist/components/dpqlEditor/useDpqlProbe.js +29 -0
- package/dist/components/dpqlEditor/useDpqlProbe.js.map +1 -0
- package/dist/components/dpqlEditor/useDpqlSession.d.ts +5 -2
- package/dist/components/dpqlEditor/useDpqlSession.d.ts.map +1 -1
- package/dist/components/dpqlEditor/useDpqlSession.js +8 -2
- package/dist/components/dpqlEditor/useDpqlSession.js.map +1 -1
- package/dist/components/form/engine/CompactRow.d.ts.map +1 -1
- package/dist/components/form/engine/CompactRow.js +414 -128
- package/dist/components/form/engine/CompactRow.js.map +1 -1
- package/dist/components/form/engine/CompactToolbar.d.ts.map +1 -1
- package/dist/components/form/engine/CompactToolbar.js +5 -2
- package/dist/components/form/engine/CompactToolbar.js.map +1 -1
- package/dist/components/form/engine/FormEngine.d.ts +273 -22
- package/dist/components/form/engine/FormEngine.d.ts.map +1 -1
- package/dist/components/form/engine/FormEngine.js +669 -192
- package/dist/components/form/engine/FormEngine.js.map +1 -1
- package/dist/components/form/engine/FormFieldsSkeleton.d.ts +48 -0
- package/dist/components/form/engine/FormFieldsSkeleton.d.ts.map +1 -0
- package/dist/components/form/engine/FormFieldsSkeleton.js +41 -0
- package/dist/components/form/engine/FormFieldsSkeleton.js.map +1 -0
- package/dist/components/form/engine/OptionFieldMessages.d.ts +108 -2
- package/dist/components/form/engine/OptionFieldMessages.d.ts.map +1 -1
- package/dist/components/form/engine/OptionFieldMessages.js +203 -13
- package/dist/components/form/engine/OptionFieldMessages.js.map +1 -1
- package/dist/components/form/engine/_structuredData/SchemaDataView.d.ts.map +1 -1
- package/dist/components/form/engine/_structuredData/SchemaDataView.js +68 -5
- package/dist/components/form/engine/_structuredData/SchemaDataView.js.map +1 -1
- package/dist/components/form/engine/compactRowContext.d.ts +15 -1
- package/dist/components/form/engine/compactRowContext.d.ts.map +1 -1
- package/dist/components/form/engine/compactRowContext.js.map +1 -1
- package/dist/components/form/engine/compactRowStyles.d.ts.map +1 -1
- package/dist/components/form/engine/compactRowStyles.js +55 -29
- package/dist/components/form/engine/compactRowStyles.js.map +1 -1
- package/dist/components/form/engine/compactToolbarContext.d.ts +1 -0
- package/dist/components/form/engine/compactToolbarContext.d.ts.map +1 -1
- package/dist/components/form/engine/optionActions.d.ts +37 -1
- package/dist/components/form/engine/optionActions.d.ts.map +1 -1
- package/dist/components/form/engine/optionActions.js +71 -1
- package/dist/components/form/engine/optionActions.js.map +1 -1
- package/dist/components/form/engine/optionsContext.d.ts +22 -0
- package/dist/components/form/engine/optionsContext.d.ts.map +1 -0
- package/dist/components/form/engine/optionsContext.js +20 -0
- package/dist/components/form/engine/optionsContext.js.map +1 -0
- package/dist/components/form/engine/readFirst.d.ts +42 -1
- package/dist/components/form/engine/readFirst.d.ts.map +1 -1
- package/dist/components/form/engine/readFirst.js +76 -8
- package/dist/components/form/engine/readFirst.js.map +1 -1
- package/dist/components/form/engine/rendererTypes.d.ts +42 -3
- package/dist/components/form/engine/rendererTypes.d.ts.map +1 -1
- package/dist/components/form/engine/rendererTypes.js +3 -1
- package/dist/components/form/engine/rendererTypes.js.map +1 -1
- package/dist/components/form/engine/rowFocus.d.ts +30 -0
- package/dist/components/form/engine/rowFocus.d.ts.map +1 -0
- package/dist/components/form/engine/rowFocus.js +93 -0
- package/dist/components/form/engine/rowFocus.js.map +1 -0
- package/dist/components/form/engine/rowMenuContext.d.ts +78 -0
- package/dist/components/form/engine/rowMenuContext.d.ts.map +1 -0
- package/dist/components/form/engine/rowMenuContext.js +103 -0
- package/dist/components/form/engine/rowMenuContext.js.map +1 -0
- package/dist/components/form/engine/rowOpenPicker.d.ts +27 -0
- package/dist/components/form/engine/rowOpenPicker.d.ts.map +1 -0
- package/dist/components/form/engine/rowOpenPicker.js +30 -0
- package/dist/components/form/engine/rowOpenPicker.js.map +1 -0
- package/dist/components/form/engine/typeChoices.d.ts +42 -0
- package/dist/components/form/engine/typeChoices.d.ts.map +1 -0
- package/dist/components/form/engine/typeChoices.js +33 -0
- package/dist/components/form/engine/typeChoices.js.map +1 -0
- package/dist/components/form/expressions/DpqlRendering.d.ts +26 -0
- package/dist/components/form/expressions/DpqlRendering.d.ts.map +1 -0
- package/dist/components/form/expressions/DpqlRendering.js +53 -0
- package/dist/components/form/expressions/DpqlRendering.js.map +1 -0
- package/dist/components/form/expressions/ExpressionField.d.ts +7 -1
- package/dist/components/form/expressions/ExpressionField.d.ts.map +1 -1
- package/dist/components/form/expressions/ExpressionField.js +203 -45
- package/dist/components/form/expressions/ExpressionField.js.map +1 -1
- package/dist/components/form/expressions/argumentPresence.d.ts +84 -0
- package/dist/components/form/expressions/argumentPresence.d.ts.map +1 -0
- package/dist/components/form/expressions/argumentPresence.js +217 -0
- package/dist/components/form/expressions/argumentPresence.js.map +1 -0
- package/dist/components/form/expressions/builder/argumentLabel.d.ts.map +1 -1
- package/dist/components/form/expressions/builder/argumentLabel.js +9 -4
- package/dist/components/form/expressions/builder/argumentLabel.js.map +1 -1
- package/dist/components/form/expressions/builder/index.d.ts +15 -2
- package/dist/components/form/expressions/builder/index.d.ts.map +1 -1
- package/dist/components/form/expressions/builder/index.js +21 -65
- package/dist/components/form/expressions/builder/index.js.map +1 -1
- package/dist/components/form/expressions/builder/renderTemplate.d.ts +4 -1
- package/dist/components/form/expressions/builder/renderTemplate.d.ts.map +1 -1
- package/dist/components/form/expressions/builder/renderTemplate.js +10 -67
- package/dist/components/form/expressions/builder/renderTemplate.js.map +1 -1
- package/dist/components/form/expressions/mockExpressions.d.ts.map +1 -1
- package/dist/components/form/expressions/mockExpressions.js +8 -4
- package/dist/components/form/expressions/mockExpressions.js.map +1 -1
- package/dist/components/form/expressions/renderExpressionToText.d.ts +1 -1
- package/dist/components/form/expressions/renderExpressionToText.d.ts.map +1 -1
- package/dist/components/form/expressions/renderExpressionToText.js +95 -19
- package/dist/components/form/expressions/renderExpressionToText.js.map +1 -1
- package/dist/components/form/expressions/types.d.ts +17 -2
- package/dist/components/form/expressions/types.d.ts.map +1 -1
- package/dist/components/form/expressions/useExpressions.d.ts.map +1 -1
- package/dist/components/form/expressions/useExpressions.js +5 -2
- package/dist/components/form/expressions/useExpressions.js.map +1 -1
- package/dist/components/form/expressions/useRenderExpression.d.ts +7 -16
- package/dist/components/form/expressions/useRenderExpression.d.ts.map +1 -1
- package/dist/components/form/expressions/useRenderExpression.js +50 -126
- package/dist/components/form/expressions/useRenderExpression.js.map +1 -1
- package/dist/components/form/fields/Field.d.ts +21 -0
- package/dist/components/form/fields/Field.d.ts.map +1 -1
- package/dist/components/form/fields/Field.js +54 -8
- package/dist/components/form/fields/Field.js.map +1 -1
- package/dist/components/form/fields/allowed-values/AllowedValues.d.ts +11 -1
- package/dist/components/form/fields/allowed-values/AllowedValues.d.ts.map +1 -1
- package/dist/components/form/fields/allowed-values/AllowedValues.js +52 -8
- package/dist/components/form/fields/allowed-values/AllowedValues.js.map +1 -1
- package/dist/components/form/fields/auto/AutoFormField.d.ts +7 -1
- package/dist/components/form/fields/auto/AutoFormField.d.ts.map +1 -1
- package/dist/components/form/fields/auto/AutoFormField.js +91 -28
- package/dist/components/form/fields/auto/AutoFormField.js.map +1 -1
- package/dist/components/form/fields/date/Date.d.ts +1 -1
- package/dist/components/form/fields/date/Date.d.ts.map +1 -1
- package/dist/components/form/fields/date/Date.js +16 -2
- package/dist/components/form/fields/date/Date.js.map +1 -1
- package/dist/components/form/fields/long-string/LongString.d.ts.map +1 -1
- package/dist/components/form/fields/long-string/LongString.js +14 -2
- package/dist/components/form/fields/long-string/LongString.js.map +1 -1
- package/dist/components/form/fields/multi-select/MultiSelectFormField.d.ts.map +1 -1
- package/dist/components/form/fields/multi-select/MultiSelectFormField.js +50 -4
- package/dist/components/form/fields/multi-select/MultiSelectFormField.js.map +1 -1
- package/dist/components/form/fields/number/Number.d.ts +12 -1
- package/dist/components/form/fields/number/Number.d.ts.map +1 -1
- package/dist/components/form/fields/number/Number.js +6 -3
- package/dist/components/form/fields/number/Number.js.map +1 -1
- package/dist/components/form/fields/rich-text/RichText.d.ts +47 -2
- package/dist/components/form/fields/rich-text/RichText.d.ts.map +1 -1
- package/dist/components/form/fields/rich-text/RichText.js +153 -12
- package/dist/components/form/fields/rich-text/RichText.js.map +1 -1
- package/dist/components/form/fields/select/Select.d.ts.map +1 -1
- package/dist/components/form/fields/select/Select.js +120 -20
- package/dist/components/form/fields/select/Select.js.map +1 -1
- package/dist/components/form/fields/select/SelectCollection.d.ts +166 -9
- package/dist/components/form/fields/select/SelectCollection.d.ts.map +1 -1
- package/dist/components/form/fields/select/SelectCollection.js +200 -7
- package/dist/components/form/fields/select/SelectCollection.js.map +1 -1
- package/dist/components/form/fields/template/ReadOnlyTemplateTag.d.ts +2 -1
- package/dist/components/form/fields/template/ReadOnlyTemplateTag.d.ts.map +1 -1
- package/dist/components/form/fields/template/ReadOnlyTemplateTag.js +3 -2
- package/dist/components/form/fields/template/ReadOnlyTemplateTag.js.map +1 -1
- package/dist/components/form/fields/template/TemplateField.d.ts +34 -2
- package/dist/components/form/fields/template/TemplateField.d.ts.map +1 -1
- package/dist/components/form/fields/template/TemplateField.js +606 -58
- package/dist/components/form/fields/template/TemplateField.js.map +1 -1
- package/dist/components/form/fields/template/TemplateText.d.ts +36 -0
- package/dist/components/form/fields/template/TemplateText.d.ts.map +1 -0
- package/dist/components/form/fields/template/TemplateText.js +80 -0
- package/dist/components/form/fields/template/TemplateText.js.map +1 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +4 -0
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/smartEditor/SmartEditor.d.ts.map +1 -1
- package/dist/components/smartEditor/SmartEditor.js +29 -8
- package/dist/components/smartEditor/SmartEditor.js.map +1 -1
- package/dist/components/smartEditor/useLspSession.d.ts +5 -1
- package/dist/components/smartEditor/useLspSession.d.ts.map +1 -1
- package/dist/components/smartEditor/useLspSession.js +16 -2
- package/dist/components/smartEditor/useLspSession.js.map +1 -1
- package/dist/components/supportTicket/TicketReplyBox.d.ts +8 -4
- package/dist/components/supportTicket/TicketReplyBox.d.ts.map +1 -1
- package/dist/components/supportTicket/TicketReplyBox.js.map +1 -1
- package/dist/helpers/common.d.ts.map +1 -1
- package/dist/helpers/common.js +7 -3
- package/dist/helpers/common.js.map +1 -1
- package/dist/helpers/dpqlDetection.d.ts +58 -0
- package/dist/helpers/dpqlDetection.d.ts.map +1 -0
- package/dist/helpers/dpqlDetection.js +164 -0
- package/dist/helpers/dpqlDetection.js.map +1 -0
- package/dist/helpers/optionUiTypes.d.ts +31 -3
- package/dist/helpers/optionUiTypes.d.ts.map +1 -1
- package/dist/helpers/optionUiTypes.js +36 -1
- package/dist/helpers/optionUiTypes.js.map +1 -1
- package/dist/helpers/options.d.ts +57 -0
- package/dist/helpers/options.d.ts.map +1 -1
- package/dist/helpers/options.js +97 -1
- package/dist/helpers/options.js.map +1 -1
- package/dist/helpers/templateItems.d.ts +47 -0
- package/dist/helpers/templateItems.d.ts.map +1 -0
- package/dist/helpers/templateItems.js +88 -0
- package/dist/helpers/templateItems.js.map +1 -0
- package/dist/helpers/templateText.d.ts +80 -0
- package/dist/helpers/templateText.d.ts.map +1 -0
- package/dist/helpers/templateText.js +291 -0
- package/dist/helpers/templateText.js.map +1 -0
- package/dist/helpers/templates.d.ts +30 -12
- package/dist/helpers/templates.d.ts.map +1 -1
- package/dist/helpers/templates.js +91 -33
- package/dist/helpers/templates.js.map +1 -1
- package/dist/helpers/validations.d.ts +35 -8
- package/dist/helpers/validations.d.ts.map +1 -1
- package/dist/helpers/validations.js +162 -25
- package/dist/helpers/validations.js.map +1 -1
- package/dist/hooks/useArgSchema.d.ts +2 -1
- package/dist/hooks/useArgSchema.d.ts.map +1 -1
- package/dist/hooks/useFetch/useFetch.d.ts +3 -1
- package/dist/hooks/useFetch/useFetch.d.ts.map +1 -1
- package/dist/hooks/useFetch/useFetch.js +47 -9
- package/dist/hooks/useFetch/useFetch.js.map +1 -1
- package/dist/hooks/useTemplates.d.ts +20 -0
- package/dist/hooks/useTemplates.d.ts.map +1 -1
- package/dist/hooks/useTemplates.js +34 -2
- package/dist/hooks/useTemplates.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/fetch.d.ts +151 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +256 -44
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/lspClient.d.ts +6 -0
- package/dist/utils/lspClient.d.ts.map +1 -1
- package/dist/utils/lspClient.js +62 -11
- package/dist/utils/lspClient.js.map +1 -1
- package/dist/utils/websocket.d.ts +6 -0
- package/dist/utils/websocket.d.ts.map +1 -1
- package/dist/utils/websocket.js +15 -7
- package/dist/utils/websocket.js.map +1 -1
- package/package.json +10 -6
- package/src/components/composer/Composer.tsx +7 -2
- package/src/components/dpqlEditor/DpqlEditor.stories.tsx +3 -119
- package/src/components/dpqlEditor/DpqlEditor.tsx +5 -2
- package/src/components/dpqlEditor/dpqlHelpers.ts +20 -1
- package/src/components/dpqlEditor/dpqlProbe.ts +165 -0
- package/src/components/dpqlEditor/dpqlTags.ts +13 -0
- package/src/components/dpqlEditor/index.ts +4 -0
- package/src/components/dpqlEditor/types.ts +38 -2
- package/src/components/dpqlEditor/useDpqlProbe.ts +33 -0
- package/src/components/dpqlEditor/useDpqlSession.ts +20 -4
- package/src/components/form/engine/CompactRow.tsx +487 -160
- package/src/components/form/engine/CompactToolbar.tsx +10 -3
- package/src/components/form/engine/FormEngine.stories.tsx +1269 -201
- package/src/components/form/engine/FormEngine.tsx +922 -270
- package/src/components/form/engine/FormEngineStickyHeaders.stories.tsx +331 -0
- package/src/components/form/engine/FormFieldsSkeleton.tsx +77 -0
- package/src/components/form/engine/OptionFieldMessages.tsx +300 -14
- package/src/components/form/engine/_structuredData/SchemaDataView.tsx +94 -3
- package/src/components/form/engine/compactRowContext.ts +15 -6
- package/src/components/form/engine/compactRowStyles.ts +56 -2
- package/src/components/form/engine/compactToolbarContext.ts +1 -1
- package/src/components/form/engine/optionActions.ts +89 -1
- package/src/components/form/engine/optionsContext.ts +24 -0
- package/src/components/form/engine/readFirst.ts +88 -8
- package/src/components/form/engine/rendererTypes.ts +48 -4
- package/src/components/form/engine/rowFocus.ts +101 -0
- package/src/components/form/engine/rowMenuContext.ts +159 -0
- package/src/components/form/engine/rowOpenPicker.ts +27 -0
- package/src/components/form/engine/typeChoices.ts +63 -0
- package/src/components/form/expressions/DpqlRendering.tsx +85 -0
- package/src/components/form/expressions/ExpressionField.stories.tsx +826 -48
- package/src/components/form/expressions/ExpressionField.tsx +269 -55
- package/src/components/form/expressions/argumentPresence.ts +213 -0
- package/src/components/form/expressions/builder/ExpressionBuilder.stories.tsx +38 -21
- package/src/components/form/expressions/builder/argumentLabel.tsx +10 -4
- package/src/components/form/expressions/builder/index.tsx +39 -81
- package/src/components/form/expressions/builder/renderTemplate.tsx +23 -56
- package/src/components/form/expressions/dpqlMockLanguage.ts +565 -0
- package/src/components/form/expressions/dpqlMockLsp.ts +109 -83
- package/src/components/form/expressions/mockExpressions.ts +8 -4
- package/src/components/form/expressions/renderExpressionToText.ts +112 -22
- package/src/components/form/expressions/types.ts +17 -2
- package/src/components/form/expressions/useExpressions.ts +5 -1
- package/src/components/form/expressions/useRenderExpression.ts +43 -127
- package/src/components/form/fields/Field.tsx +102 -20
- package/src/components/form/fields/allowed-values/AllowedValues.tsx +106 -44
- package/src/components/form/fields/auto/AutoFormField.stories.tsx +85 -18
- package/src/components/form/fields/auto/AutoFormField.tsx +97 -21
- package/src/components/form/fields/date/Date.tsx +17 -1
- package/src/components/form/fields/long-string/LongString.tsx +15 -3
- package/src/components/form/fields/multi-select/MultiSelectFormField.tsx +65 -6
- package/src/components/form/fields/number/Number.tsx +25 -0
- package/src/components/form/fields/rich-text/RichText.tsx +248 -30
- package/src/components/form/fields/select/Select.stories.tsx +392 -0
- package/src/components/form/fields/select/Select.tsx +164 -27
- package/src/components/form/fields/select/SelectCollection.tsx +350 -6
- package/src/components/form/fields/template/ReadOnlyTemplateTag.tsx +4 -2
- package/src/components/form/fields/template/TemplateField.stories.tsx +93 -14
- package/src/components/form/fields/template/TemplateField.tsx +825 -131
- package/src/components/form/fields/template/TemplateText.tsx +115 -0
- package/src/components/form/index.tsx +4 -0
- package/src/components/log/Log.stories.tsx +2 -1
- package/src/components/searchFilterBar/SearchFilterBar.stories.tsx +3 -3
- package/src/components/smartEditor/SmartEditor.tsx +41 -9
- package/src/components/smartEditor/__fixtures__/mockLspServer.ts +52 -3
- package/src/components/smartEditor/useLspSession.ts +21 -3
- package/src/components/supportTicket/TicketReplyBox.tsx +8 -4
- package/src/components/ticketThread/TicketThread.stories.tsx +1 -0
- package/src/helpers/common.ts +7 -3
- package/src/helpers/dpqlDetection.ts +209 -0
- package/src/helpers/optionUiTypes.ts +38 -0
- package/src/helpers/options.ts +96 -0
- package/src/helpers/templateItems.ts +81 -0
- package/src/helpers/templateText.ts +350 -0
- package/src/helpers/templates.ts +94 -41
- package/src/helpers/validations.ts +203 -51
- package/src/hooks/useFetch/useFetch.stories.tsx +6 -5
- package/src/hooks/useFetch/useFetch.tsx +53 -7
- package/src/hooks/useStorage/useStorage.stories.tsx +2 -1
- package/src/hooks/useTemplates.ts +41 -0
- package/src/hooks/useWebSocket/useWebsocket.stories.tsx +2 -1
- package/src/index.tsx +14 -1
- package/src/stores/currentUser/currentUser.stories.tsx +2 -1
- package/src/stories/storyNetwork.ts +92 -0
- package/src/utils/fetch.ts +311 -21
- package/src/utils/lspClient.ts +68 -11
- package/src/utils/websocket.ts +20 -9
- package/dist/components/form/engine/__fixtures__/basicFormOptions.d.ts +0 -73
- package/dist/components/form/engine/__fixtures__/basicFormOptions.d.ts.map +0 -1
- package/dist/components/form/engine/__fixtures__/basicFormOptions.js +0 -317
- package/dist/components/form/engine/__fixtures__/basicFormOptions.js.map +0 -1
- package/dist/components/form/engine/__fixtures__/fieldChromeOptions.d.ts +0 -41
- package/dist/components/form/engine/__fixtures__/fieldChromeOptions.d.ts.map +0 -1
- package/dist/components/form/engine/__fixtures__/fieldChromeOptions.js +0 -45
- package/dist/components/form/engine/__fixtures__/fieldChromeOptions.js.map +0 -1
- package/dist/components/form/expressions/dpqlMockLsp.d.ts +0 -3
- package/dist/components/form/expressions/dpqlMockLsp.d.ts.map +0 -1
- package/dist/components/form/expressions/dpqlMockLsp.js +0 -91
- package/dist/components/form/expressions/dpqlMockLsp.js.map +0 -1
- package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts +0 -2
- package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts.map +0 -1
- package/dist/components/form/fields/template/__fixtures__/longExampleValue.js +0 -9
- package/dist/components/form/fields/template/__fixtures__/longExampleValue.js.map +0 -1
- package/dist/components/smartEditor/__fixtures__/mockLspServer.d.ts +0 -55
- package/dist/components/smartEditor/__fixtures__/mockLspServer.d.ts.map +0 -1
- package/dist/components/smartEditor/__fixtures__/mockLspServer.js +0 -126
- package/dist/components/smartEditor/__fixtures__/mockLspServer.js.map +0 -1
- package/dist/stories/Data/fileFieldArgSchema.json +0 -86
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IReqoreTagProps } from '@qoretechnologies/reqore/dist/components/Tag';
|
|
2
|
+
import { TReqoreIntent } from '@qoretechnologies/reqore/dist/constants/theme';
|
|
2
3
|
import { IQorusFormField, IQorusFormSchema, TQorusForm } from '@qoretechnologies/ts-toolkit';
|
|
3
4
|
/** A `messages` entry that appears only for certain values of its siblings. */
|
|
4
5
|
export interface IConditionalFieldMessage {
|
|
@@ -35,18 +36,123 @@ export interface IConditionalFieldMessage {
|
|
|
35
36
|
export declare const isConditionalMessageShown: (message: IConditionalFieldMessage, allOptions?: TQorusForm, optionsSchema?: IQorusFormSchema) => boolean;
|
|
36
37
|
/** The subset of a field's `messages` that applies right now. */
|
|
37
38
|
export declare const getShownSchemaMessages: <T extends IConditionalFieldMessage>(messages: T[] | undefined, allOptions?: TQorusForm, optionsSchema?: IQorusFormSchema) => T[];
|
|
39
|
+
/**
|
|
40
|
+
* The whole `depends_on` list as one phrase.
|
|
41
|
+
*
|
|
42
|
+
* A nested entry is an OR — only one of its members has to hold. It used to be
|
|
43
|
+
* flattened into the same comma-separated list as the top-level entries, which
|
|
44
|
+
* are an AND, so an either/or was shown to the reader as a set of things all
|
|
45
|
+
* required. The alternatives now stay grouped and joined by "or".
|
|
46
|
+
*/
|
|
47
|
+
export declare const describeDependencies: (dependencies: (string | string[])[] | string[][], schema: IQorusFormSchema) => string;
|
|
48
|
+
/**
|
|
49
|
+
* An allowed VALUE, as far as being offered is concerned.
|
|
50
|
+
*
|
|
51
|
+
* ts-toolkit 0.5.82 carries both `IQorusAllowedValue.depends_on` and
|
|
52
|
+
* `IQorusFormFieldMessage.when` / `unless`, so this no longer waits on a publish.
|
|
53
|
+
* It remains its own shape because it states only what DECIDING AVAILABILITY needs —
|
|
54
|
+
* three keys out of the twenty an allowed value can carry — so a caller that has
|
|
55
|
+
* only those three can be answered, and the predicate cannot quietly start reading
|
|
56
|
+
* a fourth.
|
|
57
|
+
*/
|
|
58
|
+
export interface IAllowedValueAvailabilityInput {
|
|
59
|
+
/**
|
|
60
|
+
* The value is offered only while every entry holds — the SAME grammar, the
|
|
61
|
+
* same parser and the same evaluator a field's `depends_on` uses, one level
|
|
62
|
+
* down. For what this form can decide on its own.
|
|
63
|
+
*/
|
|
64
|
+
depends_on?: (string | string[])[];
|
|
65
|
+
/**
|
|
66
|
+
* Someone who already knows has refused it — the server, for a sandbox or
|
|
67
|
+
* permission context, a capability of the selected kind, or a requirement in
|
|
68
|
+
* a scope `depends_on` deliberately cannot reach.
|
|
69
|
+
*/
|
|
70
|
+
disabled?: boolean;
|
|
71
|
+
/** Where a refusal says why. */
|
|
72
|
+
messages?: IConditionalFieldMessage[];
|
|
73
|
+
}
|
|
74
|
+
/** Whether a value can be picked, and the sentence that stands in for it. */
|
|
75
|
+
export interface IAllowedValueAvailability {
|
|
76
|
+
available: boolean;
|
|
77
|
+
/** Why not. Read by the row itself, by its tooltip and by the list's search. */
|
|
78
|
+
reason?: string;
|
|
79
|
+
/** A heading the refusal came with, when it came with one. */
|
|
80
|
+
title?: string;
|
|
81
|
+
intent?: TReqoreIntent;
|
|
82
|
+
}
|
|
83
|
+
/** One object for every available value, so identity says "nothing to show". */
|
|
84
|
+
export declare const ALLOWED_VALUE_AVAILABLE: IAllowedValueAvailability;
|
|
85
|
+
/**
|
|
86
|
+
* Whether an offered value can be picked, and why not.
|
|
87
|
+
*
|
|
88
|
+
* Two things can refuse a value and they render identically, because a reader
|
|
89
|
+
* has no way to tell them apart and no reason to care:
|
|
90
|
+
*
|
|
91
|
+
* - **the predicate** — the value's own `depends_on`, judged against the form
|
|
92
|
+
* it is standing in. Whatever the form itself can decide.
|
|
93
|
+
* - **the pre-resolved refusal** — `disabled: true` with a message, from
|
|
94
|
+
* whoever already knows. A sandbox that denies a domain, a capability of the
|
|
95
|
+
* selected kind, a requirement in another value scope: none of them are
|
|
96
|
+
* reachable from a sibling's answer, and a predicate that pretended otherwise
|
|
97
|
+
* would be a predicate that never fires.
|
|
98
|
+
*
|
|
99
|
+
* The predicate is checked first when both could speak. It names a field in
|
|
100
|
+
* this very form, so the reader can act on it without leaving the row; a served
|
|
101
|
+
* reason is a statement about somewhere else.
|
|
102
|
+
*
|
|
103
|
+
* A value is never HIDDEN for either reason. A choice that vanishes takes its
|
|
104
|
+
* own explanation with it, and leaves the reader looking for something they
|
|
105
|
+
* were told exists.
|
|
106
|
+
*/
|
|
107
|
+
export declare const getAllowedValueAvailability: (value: IAllowedValueAvailabilityInput | undefined, allOptions?: TQorusForm, schema?: IQorusFormSchema) => IAllowedValueAvailability;
|
|
108
|
+
/**
|
|
109
|
+
* The availability of each offered value, against the form the picker stands in.
|
|
110
|
+
*
|
|
111
|
+
* Aligned with `items`: the result at index `i` describes `items[i]`.
|
|
112
|
+
*
|
|
113
|
+
* The answer is computed INSIDE the context selector, not from a copy of the
|
|
114
|
+
* form values pulled out of it. `OptionsContext` hands down a fresh object on
|
|
115
|
+
* every render of the engine, so a picker that selected the values themselves
|
|
116
|
+
* would re-render on every keystroke anywhere in the form; selecting the
|
|
117
|
+
* computed answer re-renders it only when an availability actually changes.
|
|
118
|
+
*
|
|
119
|
+
* Values that gate on nothing skip the computation entirely, and that is a
|
|
120
|
+
* claim about each VALUE rather than about the field it belongs to. The gate
|
|
121
|
+
* used to be one flag for the whole list, so a single gated value in a
|
|
122
|
+
* thousand-item picker resolved all thousand and serialised all thousand on
|
|
123
|
+
* every keystroke anywhere in the form. Only the gated indices are resolved
|
|
124
|
+
* and serialised; every other position is the same frozen
|
|
125
|
+
* {@link ALLOWED_VALUE_AVAILABLE}, which costs nothing to fill in and lets
|
|
126
|
+
* identity say "nothing to show".
|
|
127
|
+
*/
|
|
128
|
+
export declare const useAllowedValueAvailability: (items: readonly IAllowedValueAvailabilityInput[] | undefined) => IAllowedValueAvailability[];
|
|
38
129
|
export interface IOptionFieldMessagesProps {
|
|
39
130
|
schema: IQorusFormSchema;
|
|
40
131
|
option: IQorusFormField;
|
|
41
132
|
allOptions?: TQorusForm;
|
|
42
133
|
name: string;
|
|
43
134
|
getType: (type: string) => string;
|
|
135
|
+
/**
|
|
136
|
+
* The reader has not edited this field in this session.
|
|
137
|
+
*
|
|
138
|
+
* An error is a report that something went WRONG. "This field is required"
|
|
139
|
+
* under a field nobody has been in yet reports nothing: the form is empty
|
|
140
|
+
* because it is new. The requirement is already carried three other ways —
|
|
141
|
+
* the asterisk on the label, the Needs-attention box the row sits in, and the
|
|
142
|
+
* completion meter — so the message waits until the reader has been in the
|
|
143
|
+
* field and left it empty, which IS a thing that went wrong.
|
|
144
|
+
*
|
|
145
|
+
* Only the plain required message is held back. A value that fails
|
|
146
|
+
* validation, an unmet required GROUP and a locked dependency are all facts
|
|
147
|
+
* about what the form currently holds, and they show immediately.
|
|
148
|
+
*/
|
|
149
|
+
untouched?: boolean;
|
|
44
150
|
}
|
|
45
151
|
/**
|
|
46
152
|
* Compute the validation / required-group / dependency messages for an option —
|
|
47
153
|
* pure, so the compact read-first rows can surface the same messages the
|
|
48
154
|
* expanded editor shows (single source of truth).
|
|
49
155
|
*/
|
|
50
|
-
export declare const getOptionFieldMessages: ({ schema, option, name, allOptions, getType, }: IOptionFieldMessagesProps) => IReqoreTagProps[];
|
|
51
|
-
export declare const OptionFieldMessages: ({ schema, option, name, allOptions, getType, }: IOptionFieldMessagesProps) => import("react/jsx-runtime").JSX.Element;
|
|
156
|
+
export declare const getOptionFieldMessages: ({ schema, option, name, allOptions, getType, untouched, }: IOptionFieldMessagesProps) => IReqoreTagProps[];
|
|
157
|
+
export declare const OptionFieldMessages: ({ schema, option, name, allOptions, getType, untouched, }: IOptionFieldMessagesProps) => import("react/jsx-runtime").JSX.Element;
|
|
52
158
|
//# sourceMappingURL=OptionFieldMessages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionFieldMessages.d.ts","sourceRoot":"","sources":["../../../../src/components/form/engine/OptionFieldMessages.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"OptionFieldMessages.d.ts","sourceRoot":"","sources":["../../../../src/components/form/engine/OptionFieldMessages.tsx"],"names":[],"mappings":"AACA,O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FAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,EAAE,yBAEpC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,2BAA2B,UAC/B,8BAA8B,GAAG,SAAS,eACpC,UAAU,WACd,gBAAgB,KACxB,yBAiDF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,UAC/B,SAAS,8BAA8B,EAAE,GAAG,SAAS,KAC3D,yBAAyB,EAsC3B,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAClC;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,8DAOhC,yBAAyB,KAAG,eAAe,EA6E7C,CAAC;AAEF,eAAO,MAAM,mBAAmB,8DAO7B,yBAAyB,4CAoB3B,CAAC"}
|
|
@@ -11,13 +11,16 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.OptionFieldMessages = exports.getOptionFieldMessages = exports.getShownSchemaMessages = exports.isConditionalMessageShown = void 0;
|
|
14
|
+
exports.OptionFieldMessages = exports.getOptionFieldMessages = exports.useAllowedValueAvailability = exports.getAllowedValueAvailability = exports.ALLOWED_VALUE_AVAILABLE = exports.describeDependencies = exports.getShownSchemaMessages = exports.isConditionalMessageShown = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var reqore_1 = require("@qoretechnologies/reqore");
|
|
17
17
|
var lodash_1 = require("lodash");
|
|
18
18
|
var react_1 = require("react");
|
|
19
|
+
var use_context_selector_1 = require("use-context-selector");
|
|
19
20
|
var options_1 = require("../../../helpers/options");
|
|
21
|
+
var optionUiTypes_1 = require("../../../helpers/optionUiTypes");
|
|
20
22
|
var validations_1 = require("../../../helpers/validations");
|
|
23
|
+
var optionsContext_1 = require("./optionsContext");
|
|
21
24
|
/**
|
|
22
25
|
* Whether a schema message applies to the form as it currently stands.
|
|
23
26
|
*
|
|
@@ -41,7 +44,8 @@ var isConditionalMessageShown = function (message, allOptions, optionsSchema) {
|
|
|
41
44
|
if (message.when && !(0, validations_1.hasAllDependenciesFullfilled)(message.when, values, optionsSchema)) {
|
|
42
45
|
return false;
|
|
43
46
|
}
|
|
44
|
-
if (message.unless &&
|
|
47
|
+
if (message.unless &&
|
|
48
|
+
(0, validations_1.hasAllDependenciesFullfilled)(message.unless, values, optionsSchema)) {
|
|
45
49
|
return false;
|
|
46
50
|
}
|
|
47
51
|
return true;
|
|
@@ -50,17 +54,202 @@ exports.isConditionalMessageShown = isConditionalMessageShown;
|
|
|
50
54
|
/** The subset of a field's `messages` that applies right now. */
|
|
51
55
|
var getShownSchemaMessages = function (messages, allOptions, optionsSchema) { return (messages || []).filter(function (m) { return (0, exports.isConditionalMessageShown)(m, allOptions, optionsSchema); }); };
|
|
52
56
|
exports.getShownSchemaMessages = getShownSchemaMessages;
|
|
57
|
+
/**
|
|
58
|
+
* Name one `depends_on` entry so the reader can act on it.
|
|
59
|
+
*
|
|
60
|
+
* The list used to be built by looking each entry up as a whole field name,
|
|
61
|
+
* which is only ever true of the bare-name form. A COMPARISON entry
|
|
62
|
+
* (`kind=type`, `kind!=type`) matched no field, was dropped, and a field whose
|
|
63
|
+
* dependencies are all comparisons — the shape every subject field of a test
|
|
64
|
+
* uses — rendered "…are not fulfilled:" with nothing after the colon. The
|
|
65
|
+
* reader was told a dependency was unmet and not which one, by a sentence that
|
|
66
|
+
* stopped mid-way.
|
|
67
|
+
*
|
|
68
|
+
* One parser for both halves, the same one the evaluator uses, so the sentence
|
|
69
|
+
* and the lock cannot disagree about what an entry means.
|
|
70
|
+
*/
|
|
71
|
+
var describeDependency = function (dependency, schema) {
|
|
72
|
+
var _a = (0, validations_1.parseDependency)(dependency), name = _a.name, op = _a.op, value = _a.value;
|
|
73
|
+
var dependencySchema = schema[name];
|
|
74
|
+
if (!dependencySchema) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
var label = "\"".concat(dependencySchema.display_name || name, "\"");
|
|
78
|
+
// `!name` names no value to compare against — it is satisfied by the sibling
|
|
79
|
+
// being unanswered — so it gets a sentence of its own rather than the
|
|
80
|
+
// comparison template, which would read `must not be "undefined"`.
|
|
81
|
+
if (op === '!') {
|
|
82
|
+
return "".concat(label, " must have no value");
|
|
83
|
+
}
|
|
84
|
+
return op ? "".concat(label, " must ").concat(op === '!=' ? 'not ' : '', "be \"").concat(value, "\"") : label;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The whole `depends_on` list as one phrase.
|
|
88
|
+
*
|
|
89
|
+
* A nested entry is an OR — only one of its members has to hold. It used to be
|
|
90
|
+
* flattened into the same comma-separated list as the top-level entries, which
|
|
91
|
+
* are an AND, so an either/or was shown to the reader as a set of things all
|
|
92
|
+
* required. The alternatives now stay grouped and joined by "or".
|
|
93
|
+
*/
|
|
94
|
+
var describeDependencies = function (dependencies, schema) {
|
|
95
|
+
return dependencies
|
|
96
|
+
.map(function (entry) {
|
|
97
|
+
if (!(0, lodash_1.isArray)(entry)) {
|
|
98
|
+
return describeDependency(entry, schema);
|
|
99
|
+
}
|
|
100
|
+
var alternatives = entry
|
|
101
|
+
.map(function (dep) { return describeDependency(dep, schema); })
|
|
102
|
+
.filter(function (dep) { return !!dep; });
|
|
103
|
+
if (!alternatives.length) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return alternatives.length > 1 ? "(".concat(alternatives.join(' or '), ")") : alternatives[0];
|
|
107
|
+
})
|
|
108
|
+
.filter(function (entry) { return !!entry; })
|
|
109
|
+
.join(', ');
|
|
110
|
+
};
|
|
111
|
+
exports.describeDependencies = describeDependencies;
|
|
112
|
+
/** One object for every available value, so identity says "nothing to show". */
|
|
113
|
+
exports.ALLOWED_VALUE_AVAILABLE = Object.freeze({
|
|
114
|
+
available: true,
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Whether an offered value can be picked, and why not.
|
|
118
|
+
*
|
|
119
|
+
* Two things can refuse a value and they render identically, because a reader
|
|
120
|
+
* has no way to tell them apart and no reason to care:
|
|
121
|
+
*
|
|
122
|
+
* - **the predicate** — the value's own `depends_on`, judged against the form
|
|
123
|
+
* it is standing in. Whatever the form itself can decide.
|
|
124
|
+
* - **the pre-resolved refusal** — `disabled: true` with a message, from
|
|
125
|
+
* whoever already knows. A sandbox that denies a domain, a capability of the
|
|
126
|
+
* selected kind, a requirement in another value scope: none of them are
|
|
127
|
+
* reachable from a sibling's answer, and a predicate that pretended otherwise
|
|
128
|
+
* would be a predicate that never fires.
|
|
129
|
+
*
|
|
130
|
+
* The predicate is checked first when both could speak. It names a field in
|
|
131
|
+
* this very form, so the reader can act on it without leaving the row; a served
|
|
132
|
+
* reason is a statement about somewhere else.
|
|
133
|
+
*
|
|
134
|
+
* A value is never HIDDEN for either reason. A choice that vanishes takes its
|
|
135
|
+
* own explanation with it, and leaves the reader looking for something they
|
|
136
|
+
* were told exists.
|
|
137
|
+
*/
|
|
138
|
+
var getAllowedValueAvailability = function (value, allOptions, schema) {
|
|
139
|
+
if (!value) {
|
|
140
|
+
return exports.ALLOWED_VALUE_AVAILABLE;
|
|
141
|
+
}
|
|
142
|
+
/* `allOptions` is undefined only when there is no form around the picker at
|
|
143
|
+
all (see `OptionsContext`). A predicate about siblings has nothing to judge
|
|
144
|
+
there, and locking every gated value in a standalone picker would be a
|
|
145
|
+
rendering fault rather than a fact about the form. */
|
|
146
|
+
if ((0, lodash_1.size)(value.depends_on) &&
|
|
147
|
+
allOptions &&
|
|
148
|
+
!(0, validations_1.hasAllDependenciesFullfilled)(value.depends_on, allOptions, schema)) {
|
|
149
|
+
var dependsOn = schema ? (0, exports.describeDependencies)(value.depends_on, schema) : '';
|
|
150
|
+
return {
|
|
151
|
+
available: false,
|
|
152
|
+
intent: 'warning',
|
|
153
|
+
reason: dependsOn ?
|
|
154
|
+
"Unavailable because some dependencies are not fulfilled: ".concat(dependsOn)
|
|
155
|
+
// Nothing nameable: every entry pointed at a field this schema does
|
|
156
|
+
// not contain. A sentence that ends in a colon and then stops reads
|
|
157
|
+
// as a rendering fault rather than as a fact about the form.
|
|
158
|
+
: 'Unavailable because some dependencies are not fulfilled',
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (value.disabled) {
|
|
162
|
+
/* The refusal picks its own words out of `messages`, through the same
|
|
163
|
+
`when`/`unless` filter a field's messages go through — a served reason
|
|
164
|
+
can itself be conditional. The most serious one speaks: a `danger`
|
|
165
|
+
message is the one that explains a refusal, and an `info` note beside it
|
|
166
|
+
is not. */
|
|
167
|
+
var explanation = (0, options_1.getRefusalMessage)((0, exports.getShownSchemaMessages)(value.messages, allOptions, schema));
|
|
168
|
+
return {
|
|
169
|
+
available: false,
|
|
170
|
+
intent: (explanation === null || explanation === void 0 ? void 0 : explanation.intent) || 'warning',
|
|
171
|
+
title: explanation === null || explanation === void 0 ? void 0 : explanation.title,
|
|
172
|
+
// A refusal with no message at all still has to say something: silence
|
|
173
|
+
// over a value that will not respond is the defect this whole mechanism
|
|
174
|
+
// exists to remove.
|
|
175
|
+
reason: (explanation === null || explanation === void 0 ? void 0 : explanation.content) || options_1.UNAVAILABLE_VALUE_FALLBACK_REASON,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return exports.ALLOWED_VALUE_AVAILABLE;
|
|
179
|
+
};
|
|
180
|
+
exports.getAllowedValueAvailability = getAllowedValueAvailability;
|
|
181
|
+
/**
|
|
182
|
+
* The availability of each offered value, against the form the picker stands in.
|
|
183
|
+
*
|
|
184
|
+
* Aligned with `items`: the result at index `i` describes `items[i]`.
|
|
185
|
+
*
|
|
186
|
+
* The answer is computed INSIDE the context selector, not from a copy of the
|
|
187
|
+
* form values pulled out of it. `OptionsContext` hands down a fresh object on
|
|
188
|
+
* every render of the engine, so a picker that selected the values themselves
|
|
189
|
+
* would re-render on every keystroke anywhere in the form; selecting the
|
|
190
|
+
* computed answer re-renders it only when an availability actually changes.
|
|
191
|
+
*
|
|
192
|
+
* Values that gate on nothing skip the computation entirely, and that is a
|
|
193
|
+
* claim about each VALUE rather than about the field it belongs to. The gate
|
|
194
|
+
* used to be one flag for the whole list, so a single gated value in a
|
|
195
|
+
* thousand-item picker resolved all thousand and serialised all thousand on
|
|
196
|
+
* every keystroke anywhere in the form. Only the gated indices are resolved
|
|
197
|
+
* and serialised; every other position is the same frozen
|
|
198
|
+
* {@link ALLOWED_VALUE_AVAILABLE}, which costs nothing to fill in and lets
|
|
199
|
+
* identity say "nothing to show".
|
|
200
|
+
*/
|
|
201
|
+
var useAllowedValueAvailability = function (items) {
|
|
202
|
+
var gatedIndices = (0, react_1.useMemo)(function () {
|
|
203
|
+
return (items || []).reduce(function (indices, item, index) {
|
|
204
|
+
if ((0, lodash_1.size)(item === null || item === void 0 ? void 0 : item.depends_on) || (item === null || item === void 0 ? void 0 : item.disabled) === true) {
|
|
205
|
+
indices.push(index);
|
|
206
|
+
}
|
|
207
|
+
return indices;
|
|
208
|
+
}, []);
|
|
209
|
+
}, [items]);
|
|
210
|
+
var serialized = (0, use_context_selector_1.useContextSelector)(optionsContext_1.OptionsContext, function (context) {
|
|
211
|
+
return gatedIndices.length ?
|
|
212
|
+
JSON.stringify(gatedIndices.map(function (index) {
|
|
213
|
+
return (0, exports.getAllowedValueAvailability)(items[index], context.value, context.schema);
|
|
214
|
+
}))
|
|
215
|
+
: '';
|
|
216
|
+
});
|
|
217
|
+
return (0, react_1.useMemo)(function () {
|
|
218
|
+
var result = (items || []).map(function () { return exports.ALLOWED_VALUE_AVAILABLE; });
|
|
219
|
+
if (!serialized) {
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
// Aligned back onto the caller's own indices: the picker asks for
|
|
223
|
+
// `availability[i]` and must get the answer for `items[i]`.
|
|
224
|
+
var resolved = JSON.parse(serialized);
|
|
225
|
+
gatedIndices.forEach(function (index, position) {
|
|
226
|
+
result[index] = resolved[position];
|
|
227
|
+
});
|
|
228
|
+
return result;
|
|
229
|
+
}, [serialized, items, gatedIndices]);
|
|
230
|
+
};
|
|
231
|
+
exports.useAllowedValueAvailability = useAllowedValueAvailability;
|
|
53
232
|
/**
|
|
54
233
|
* Compute the validation / required-group / dependency messages for an option —
|
|
55
234
|
* pure, so the compact read-first rows can surface the same messages the
|
|
56
235
|
* expanded editor shows (single source of truth).
|
|
57
236
|
*/
|
|
58
237
|
var getOptionFieldMessages = function (_a) {
|
|
59
|
-
var schema = _a.schema, option = _a.option, name = _a.name, allOptions = _a.allOptions, getType = _a.getType;
|
|
238
|
+
var schema = _a.schema, option = _a.option, name = _a.name, allOptions = _a.allOptions, getType = _a.getType, untouched = _a.untouched;
|
|
60
239
|
var optionSchema = schema[name];
|
|
61
240
|
var result = [];
|
|
62
241
|
if (option.value || option.value === false || option.value === 0 || option.value === null) {
|
|
63
|
-
|
|
242
|
+
/* A concrete type the VALUE carries beats an untyped schema.
|
|
243
|
+
`auto`/`any` declare no type — the author picks one (Binary, Date, …)
|
|
244
|
+
and it is recorded beside the value. Reading the schema first validated
|
|
245
|
+
a binary value as `auto`, which auto-detects from the value and accepts
|
|
246
|
+
anything, so the form said the field needed attention while the field
|
|
247
|
+
itself gave no reason. The form's own check already prefers the stored
|
|
248
|
+
type (`getOptionFieldStorageType`); this is the same precedence. */
|
|
249
|
+
var schemaType = optionSchema === null || optionSchema === void 0 ? void 0 : optionSchema.ui_type;
|
|
250
|
+
var storedType = option.type;
|
|
251
|
+
var typeToValidate = (0, optionUiTypes_1.isUntypedOptionType)(schemaType) && storedType ? storedType : schemaType || storedType;
|
|
252
|
+
var validationData = (0, validations_1.validateFieldWithResult)(getType(typeToValidate), option.value, __assign(__assign({ has_to_have_value: true, isFunction: option.is_expression }, optionSchema), { optionSchema: schema }));
|
|
64
253
|
if (!validationData.isValid) {
|
|
65
254
|
result.push({
|
|
66
255
|
label: validationData.reason || 'Field value is not valid',
|
|
@@ -69,7 +258,7 @@ var getOptionFieldMessages = function (_a) {
|
|
|
69
258
|
}
|
|
70
259
|
}
|
|
71
260
|
else {
|
|
72
|
-
if (optionSchema === null || optionSchema === void 0 ? void 0 : optionSchema.required) {
|
|
261
|
+
if ((optionSchema === null || optionSchema === void 0 ? void 0 : optionSchema.required) && !untouched) {
|
|
73
262
|
result.push({ label: 'This field is required', intent: 'danger' });
|
|
74
263
|
}
|
|
75
264
|
if ((optionSchema === null || optionSchema === void 0 ? void 0 : optionSchema.required_groups) &&
|
|
@@ -83,13 +272,14 @@ var getOptionFieldMessages = function (_a) {
|
|
|
83
272
|
}
|
|
84
273
|
if ((optionSchema === null || optionSchema === void 0 ? void 0 : optionSchema.depends_on) &&
|
|
85
274
|
!(0, validations_1.hasAllDependenciesFullfilled)(optionSchema.depends_on, allOptions, schema)) {
|
|
86
|
-
var dependsOn = (0,
|
|
87
|
-
.filter(function (dep) { return !!schema[dep]; })
|
|
88
|
-
.map(function (dep) { return schema[dep].display_name || dep; })
|
|
89
|
-
.map(function (dep) { return "\"".concat(dep, "\""); })
|
|
90
|
-
.join(', ');
|
|
275
|
+
var dependsOn = (0, exports.describeDependencies)(optionSchema.depends_on, schema);
|
|
91
276
|
result.push({
|
|
92
|
-
label:
|
|
277
|
+
label: dependsOn ?
|
|
278
|
+
"This field is disabled because some dependencies are not fulfilled: ".concat(dependsOn)
|
|
279
|
+
// Nothing nameable: every entry pointed at a field this schema does
|
|
280
|
+
// not contain. A sentence that ends in a colon and then stops reads
|
|
281
|
+
// as a rendering fault rather than as a fact about the form.
|
|
282
|
+
: 'This field is disabled because some dependencies are not fulfilled',
|
|
93
283
|
intent: 'warning',
|
|
94
284
|
});
|
|
95
285
|
}
|
|
@@ -97,8 +287,8 @@ var getOptionFieldMessages = function (_a) {
|
|
|
97
287
|
};
|
|
98
288
|
exports.getOptionFieldMessages = getOptionFieldMessages;
|
|
99
289
|
var OptionFieldMessages = function (_a) {
|
|
100
|
-
var schema = _a.schema, option = _a.option, name = _a.name, allOptions = _a.allOptions, getType = _a.getType;
|
|
101
|
-
var messages = (0, react_1.useMemo)(function () { return (0, exports.getOptionFieldMessages)({ schema: schema, option: option, name: name, allOptions: allOptions, getType: getType }); }, [JSON.stringify(schema), JSON.stringify(option), JSON.stringify(allOptions), name]);
|
|
290
|
+
var schema = _a.schema, option = _a.option, name = _a.name, allOptions = _a.allOptions, getType = _a.getType, untouched = _a.untouched;
|
|
291
|
+
var messages = (0, react_1.useMemo)(function () { return (0, exports.getOptionFieldMessages)({ schema: schema, option: option, name: name, allOptions: allOptions, getType: getType, untouched: untouched }); }, [JSON.stringify(schema), JSON.stringify(option), JSON.stringify(allOptions), name, untouched]);
|
|
102
292
|
if (!(0, lodash_1.size)(messages)) {
|
|
103
293
|
return null;
|
|
104
294
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionFieldMessages.js","sourceRoot":"","sources":["../../../../src/components/form/engine/OptionFieldMessages.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAA+F;
|
|
1
|
+
{"version":3,"file":"OptionFieldMessages.js","sourceRoot":"","sources":["../../../../src/components/form/engine/OptionFieldMessages.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAA+F;AAI/F,iCAAuC;AACvC,+BAAgC;AAChC,6DAA0D;AAC1D,oDAIkC;AAClC,gEA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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDataView.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/engine/_structuredData/SchemaDataView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SchemaDataView.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/engine/_structuredData/SchemaDataView.tsx"],"names":[],"mappings":"AAQA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAqQ1B,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,KAAK,EAAE,OAAO,CAAC;IACf,iEAAiE;IACjE,MAAM,EAAE,gBAAgB,CAAC;IACzB,uDAAuD;IACvD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;;OASG;IACH,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAgaD,eAAO,MAAM,cAAc,gFAC2B,oBAAoB,6CASzE,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,UAAW,OAAO,UAAU,OAAO,KAAG,OASrE,CAAC"}
|
|
@@ -10,12 +10,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.canRenderWithSchema = exports.SchemaDataView = void 0;
|
|
11
11
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
12
12
|
var reqore_1 = require("@qoretechnologies/reqore");
|
|
13
|
+
var templateText_1 = require("../../../../helpers/templateText");
|
|
13
14
|
var react_1 = __importDefault(require("react"));
|
|
14
15
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
15
16
|
var use_context_selector_1 = require("use-context-selector");
|
|
16
17
|
var compactRowContext_1 = require("../compactRowContext");
|
|
17
18
|
var compactRowStyles_1 = require("../compactRowStyles");
|
|
18
19
|
var readFirst_1 = require("../readFirst");
|
|
20
|
+
var TemplateText_1 = require("../../fields/template/TemplateText");
|
|
19
21
|
var structuredData_1 = require("./structuredData");
|
|
20
22
|
/**
|
|
21
23
|
* A read-only rendering of a value THROUGH the schema that describes it.
|
|
@@ -215,13 +217,40 @@ var labelColumn = function (value, schema) {
|
|
|
215
217
|
var isNavigableUrl = function (value) {
|
|
216
218
|
return typeof value === 'string' && /^(https?|wss?|ftps?):\/\//i.test(value);
|
|
217
219
|
};
|
|
220
|
+
/**
|
|
221
|
+
* The reference chips inside a formatted value — none when it holds no
|
|
222
|
+
* reference at all.
|
|
223
|
+
*
|
|
224
|
+
* The preview is the SAME value the row above draws, one level down, and it
|
|
225
|
+
* reached the mono cell as a raw string: a sub-field holding
|
|
226
|
+
* `$._case.mode != 'simulate'` read as a chip on the row and as the engine's
|
|
227
|
+
* own spelling in the inset beneath it, which is a row disagreeing with itself
|
|
228
|
+
* about what its value is.
|
|
229
|
+
*
|
|
230
|
+
* A field's OWN list and grammar win where it declares them — the same
|
|
231
|
+
* precedence the rows use — falling back to the form's shared catalogue.
|
|
232
|
+
*/
|
|
233
|
+
var referenceSegments = function (text, templates, fieldSchema) {
|
|
234
|
+
var _a;
|
|
235
|
+
if (typeof text !== 'string' || !text) {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
var own = fieldSchema;
|
|
239
|
+
var segments = (0, templateText_1.templateTextSegments)(text, (_a = own === null || own === void 0 ? void 0 : own.templates) !== null && _a !== void 0 ? _a : templates, own === null || own === void 0 ? void 0 : own.templateToken);
|
|
240
|
+
return segments.some(function (segment) { return segment.kind === 'tag'; }) ? segments : [];
|
|
241
|
+
};
|
|
218
242
|
/** One field's value, rendered the way its row above renders it. */
|
|
219
243
|
var FieldValue = function (_a) {
|
|
244
|
+
var _b;
|
|
220
245
|
var field = _a.field, fieldSchema = _a.fieldSchema, color = _a.color;
|
|
221
246
|
var formatted = (0, readFirst_1.formatOptionValue)(field, fieldSchema);
|
|
222
247
|
// An allowed value that carries a logo shows it here too, exactly as the row
|
|
223
248
|
// above does — the preview is the same value, so it gets the same treatment.
|
|
249
|
+
// An option marked with an ICON rather than a logo gets the same, for the same
|
|
250
|
+
// reason: the mark is how a list of bare words is told apart, and dropping it
|
|
251
|
+
// here would make the preview disagree with the row it previews.
|
|
224
252
|
var image = (0, readFirst_1.getAllowedValueImage)(field.value, fieldSchema);
|
|
253
|
+
var icon = (0, readFirst_1.getAllowedValueIcon)(field.value, fieldSchema);
|
|
225
254
|
// Data reads in mono; a chosen label does not.
|
|
226
255
|
//
|
|
227
256
|
// "qorus-session" is a literal the author typed — an identifier where the
|
|
@@ -231,18 +260,43 @@ var FieldValue = function (_a) {
|
|
|
231
260
|
// dress up a label as a value. Resolving through `allowed_values` is what
|
|
232
261
|
// separates the two, and it is the same lookup that produced the text.
|
|
233
262
|
var isChosenLabel = !!(0, readFirst_1.findAllowedValueOption)(field.value, fieldSchema);
|
|
263
|
+
/* Read from context, like the code renderer above: a level is arbitrarily
|
|
264
|
+
deep, and the form's catalogue is a property of the form rather than of any
|
|
265
|
+
one level. See `referenceSegments`. */
|
|
266
|
+
var templates = (0, use_context_selector_1.useContextSelector)(compactRowContext_1.CompactRowContext, function (v) { return v.templates; });
|
|
267
|
+
var fieldTemplates = (_b = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.templates) !== null && _b !== void 0 ? _b : templates;
|
|
268
|
+
var segments = isNavigableUrl(field.value) ? [] : referenceSegments(formatted, templates, fieldSchema);
|
|
234
269
|
return ((0, jsx_runtime_1.jsx)(compactRowStyles_1.StyledRowValue, { "$color": color, children: field.value === true || field.value === false ?
|
|
235
270
|
(0, jsx_runtime_1.jsx)(reqore_1.ReqoreTag, { size: 'small', minimal: true, intent: field.value === true ? 'success' : 'danger', label: formatted })
|
|
236
271
|
: (0, jsx_runtime_1.jsxs)("span", { className: "options-readfirst-valuetext".concat(isChosenLabel ? '' : ' schema-view-data'), style: isChosenLabel ? undefined : { fontFamily: compactRowStyles_1.MONO_FONT_STACK }, children: [image ?
|
|
237
272
|
(0, jsx_runtime_1.jsx)(reqore_1.ReqoreIcon, { image: image, size: '14px', style: { flexShrink: 0, marginRight: 6, verticalAlign: 'middle' } })
|
|
238
|
-
:
|
|
273
|
+
: icon ?
|
|
274
|
+
(0, jsx_runtime_1.jsx)(reqore_1.ReqoreIcon, { icon: icon, size: '14px', style: { flexShrink: 0, marginRight: 6, verticalAlign: 'middle' } })
|
|
275
|
+
: null, isNavigableUrl(field.value) ?
|
|
239
276
|
// The address IS the link — it used to render as inert text with a
|
|
240
277
|
// separate icon button beside it to open it, which is two things
|
|
241
278
|
// where there is one. ReqoreLink renders a real anchor, so
|
|
242
279
|
// middle-click and "copy link address" still work;
|
|
243
280
|
// `stopPropagation` because the row around it toggles.
|
|
244
281
|
(0, jsx_runtime_1.jsx)(reqore_1.ReqoreLink, { className: 'schema-view-open-url', href: field.value, target: '_blank', rel: 'noreferrer noopener', onClick: function (event) { return event.stopPropagation(); }, children: formatted })
|
|
245
|
-
:
|
|
282
|
+
: segments.length ?
|
|
283
|
+
// `full`: the preview is where a value that the row had to cut is
|
|
284
|
+
// shown whole, so its chips wrap rather than clipping.
|
|
285
|
+
(0, jsx_runtime_1.jsx)(TemplateText_1.TemplateText, { segments: segments, templates: fieldTemplates, full: true })
|
|
286
|
+
: formatted] }) }));
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* A value with no field schema of its own — a bare entry in a list, a level
|
|
290
|
+
* that turned out to be a scalar. It still reads as prose with named chips
|
|
291
|
+
* where it holds references, because a reference is not more raw for having
|
|
292
|
+
* arrived without a schema.
|
|
293
|
+
*/
|
|
294
|
+
var ScalarText = function (_a) {
|
|
295
|
+
var text = _a.text, templates = _a.templates;
|
|
296
|
+
var segments = referenceSegments(text, templates);
|
|
297
|
+
return segments.length ?
|
|
298
|
+
(0, jsx_runtime_1.jsx)(TemplateText_1.TemplateText, { segments: segments, templates: templates, full: true })
|
|
299
|
+
: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: text });
|
|
246
300
|
};
|
|
247
301
|
/** One described hash: its fields as label/value pairs in the shared columns. */
|
|
248
302
|
var SchemaRecord = function (_a) {
|
|
@@ -302,6 +356,9 @@ var SchemaRecord = function (_a) {
|
|
|
302
356
|
var SchemaLevel = function (_a) {
|
|
303
357
|
var value = _a.value, schema = _a.schema, showTypes = _a.showTypes, colors = _a.colors;
|
|
304
358
|
var inner = unwrap(value);
|
|
359
|
+
// Same reason as `FieldValue`: a heading and a bare list entry are values too,
|
|
360
|
+
// and a reference in one reads as a name everywhere else in the form.
|
|
361
|
+
var templates = (0, use_context_selector_1.useContextSelector)(compactRowContext_1.CompactRowContext, function (v) { return v.templates; });
|
|
305
362
|
if (Array.isArray(inner)) {
|
|
306
363
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: inner.map(function (item, index) {
|
|
307
364
|
var record = unwrap(item);
|
|
@@ -311,15 +368,21 @@ var SchemaLevel = function (_a) {
|
|
|
311
368
|
if (!identity) {
|
|
312
369
|
return null;
|
|
313
370
|
}
|
|
314
|
-
|
|
371
|
+
// An item is headed by one of its own fields, so the
|
|
372
|
+
// heading is that field's value and reads like it: a case
|
|
373
|
+
// named by a reference is named by the reference's NAME.
|
|
374
|
+
var titleSegments = referenceSegments(identity.text, templates, schema[identity.key]);
|
|
375
|
+
return ((0, jsx_runtime_1.jsx)(StyledItemTitle, { className: 'schema-view-item-title', "$color": colors.key, "$mono": identity.mono, "$accent": colors.accent, title: identity.label, children: titleSegments.length ?
|
|
376
|
+
(0, jsx_runtime_1.jsx)(TemplateText_1.TemplateText, { segments: titleSegments, templates: templates, full: true })
|
|
377
|
+
: identity.text }));
|
|
315
378
|
})(), (0, jsx_runtime_1.jsx)(SchemaRecord, { record: record, schema: schema, showTypes: showTypes, colors: colors, skipKey: (0, readFirst_1.titleKeyFor)(record, schema) })] })
|
|
316
|
-
: (0, jsx_runtime_1.jsx)(compactRowStyles_1.StyledRowValue, { "$color": colors.key, children: (0, jsx_runtime_1.jsx)("span", { className: 'options-readfirst-valuetext schema-view-data', style: { fontFamily: compactRowStyles_1.MONO_FONT_STACK }, children: (0, readFirst_1.formatOptionValue)({ value: record }) }) }) })] }, index));
|
|
379
|
+
: (0, jsx_runtime_1.jsx)(compactRowStyles_1.StyledRowValue, { "$color": colors.key, children: (0, jsx_runtime_1.jsx)("span", { className: 'options-readfirst-valuetext schema-view-data', style: { fontFamily: compactRowStyles_1.MONO_FONT_STACK }, children: (0, jsx_runtime_1.jsx)(ScalarText, { text: (0, readFirst_1.formatOptionValue)({ value: record }), templates: templates }) }) }) })] }, index));
|
|
317
380
|
}) }));
|
|
318
381
|
}
|
|
319
382
|
if (isRecord(inner)) {
|
|
320
383
|
return (0, jsx_runtime_1.jsx)(SchemaRecord, { record: inner, schema: schema, showTypes: showTypes, colors: colors });
|
|
321
384
|
}
|
|
322
|
-
return ((0, jsx_runtime_1.jsx)(reqore_1.ReqoreP, { size: 'small', style: { color: colors.key }, children: (0, readFirst_1.formatOptionValue)({ value: inner }) }));
|
|
385
|
+
return ((0, jsx_runtime_1.jsx)(reqore_1.ReqoreP, { size: 'small', style: { color: colors.key }, children: (0, jsx_runtime_1.jsx)(ScalarText, { text: (0, readFirst_1.formatOptionValue)({ value: inner }), templates: templates }) }));
|
|
323
386
|
};
|
|
324
387
|
exports.SchemaDataView = react_1.default.memo(function (_a) {
|
|
325
388
|
var _b;
|