@sanity/assist 1.2.15-lang.7 → 1.2.15-lang.9
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/README.md +15 -3
- package/dist/index.esm.js +185 -76
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +185 -76
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/assistInspector/AssistInspector.tsx +6 -0
- package/src/assistInspector/helpers.ts +3 -3
- package/src/coverage/.tmp/coverage-0.json +1 -0
- package/src/coverage/base.css +224 -0
- package/src/coverage/block-navigation.js +87 -0
- package/src/coverage/clover.xml +8613 -0
- package/src/coverage/coverage-final.json +107 -0
- package/src/coverage/favicon.png +0 -0
- package/src/coverage/index.html +461 -0
- package/src/coverage/lcov-report/base.css +224 -0
- package/src/coverage/lcov-report/block-navigation.js +87 -0
- package/src/coverage/lcov-report/favicon.png +0 -0
- package/src/coverage/lcov-report/index.html +461 -0
- package/src/coverage/lcov-report/prettify.css +1 -0
- package/src/coverage/lcov-report/prettify.js +2 -0
- package/src/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/src/coverage/lcov-report/sorter.js +196 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectFromRegion.tsx.html +157 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectToRegion.tsx.html +151 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorRegion.tsx.html +154 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorsProvider.tsx.html +142 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorsStore.ts.html +451 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorsStoreContext.ts.html +97 -0
- package/src/coverage/lcov-report/src/_lib/connector/helpers.ts.html +100 -0
- package/src/coverage/lcov-report/src/_lib/connector/index.html +281 -0
- package/src/coverage/lcov-report/src/_lib/connector/index.ts.html +112 -0
- package/src/coverage/lcov-report/src/_lib/connector/mapConnectorToLine.ts.html +334 -0
- package/src/coverage/lcov-report/src/_lib/connector/types.ts.html +253 -0
- package/src/coverage/lcov-report/src/_lib/connector/useConnectorsStore.ts.html +124 -0
- package/src/coverage/lcov-report/src/_lib/connector/useRegionRects.ts.html +508 -0
- package/src/coverage/lcov-report/src/_lib/fixedListenQuery.ts.html +388 -0
- package/src/coverage/lcov-report/src/_lib/form/DocumentForm.tsx.html +676 -0
- package/src/coverage/lcov-report/src/_lib/form/helpers.ts.html +178 -0
- package/src/coverage/lcov-report/src/_lib/form/index.html +146 -0
- package/src/coverage/lcov-report/src/_lib/form/index.ts.html +88 -0
- package/src/coverage/lcov-report/src/_lib/index.html +161 -0
- package/src/coverage/lcov-report/src/_lib/randomKey.ts.html +172 -0
- package/src/coverage/lcov-report/src/_lib/useListeningQuery.ts.html +268 -0
- package/src/coverage/lcov-report/src/_lib/usePrevious.ts.html +112 -0
- package/src/coverage/lcov-report/src/assistConnectors/AssistConnectorsOverlay.tsx.html +481 -0
- package/src/coverage/lcov-report/src/assistConnectors/ConnectorPath.tsx.html +271 -0
- package/src/coverage/lcov-report/src/assistConnectors/draw/arrowPath.ts.html +112 -0
- package/src/coverage/lcov-report/src/assistConnectors/draw/connectorPath.ts.html +511 -0
- package/src/coverage/lcov-report/src/assistConnectors/draw/index.html +131 -0
- package/src/coverage/lcov-report/src/assistConnectors/index.html +146 -0
- package/src/coverage/lcov-report/src/assistConnectors/index.ts.html +88 -0
- package/src/coverage/lcov-report/src/assistDocument/AssistDocumentContext.tsx.html +178 -0
- package/src/coverage/lcov-report/src/assistDocument/AssistDocumentContextProvider.tsx.html +136 -0
- package/src/coverage/lcov-report/src/assistDocument/AssistDocumentInput.tsx.html +280 -0
- package/src/coverage/lcov-report/src/assistDocument/RequestRunInstructionProvider.tsx.html +283 -0
- package/src/coverage/lcov-report/src/assistDocument/components/AssistDocumentForm.tsx.html +775 -0
- package/src/coverage/lcov-report/src/assistDocument/components/FieldRefPreview.tsx.html +166 -0
- package/src/coverage/lcov-report/src/assistDocument/components/InstructionsArrayField.tsx.html +109 -0
- package/src/coverage/lcov-report/src/assistDocument/components/InstructionsArrayInput.tsx.html +163 -0
- package/src/coverage/lcov-report/src/assistDocument/components/SelectedFieldContext.tsx.html +115 -0
- package/src/coverage/lcov-report/src/assistDocument/components/generic/HiddenFieldTitle.tsx.html +100 -0
- package/src/coverage/lcov-report/src/assistDocument/components/generic/index.html +116 -0
- package/src/coverage/lcov-report/src/assistDocument/components/helpers.ts.html +148 -0
- package/src/coverage/lcov-report/src/assistDocument/components/index.html +191 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/BackToInstructionsLink.tsx.html +178 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/FieldRefInput.tsx.html +244 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/InstructionInput.tsx.html +349 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/InstructionOutputField.tsx.html +220 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/InstructionOutputInput.tsx.html +700 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/PromptInput.tsx.html +241 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/appearance/IconInput.tsx.html +223 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/appearance/InstructionVisibility.tsx.html +196 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/appearance/index.html +131 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/index.html +191 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/index.html +161 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useAssistDocumentContextValue.tsx.html +289 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useDocumentState.ts.html +103 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useInstructionToaster.tsx.html +307 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useStudioAssistDocument.ts.html +379 -0
- package/src/coverage/lcov-report/src/assistDocument/index.html +176 -0
- package/src/coverage/lcov-report/src/assistDocument/index.ts.html +88 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistField.tsx.html +301 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistFormBlock.tsx.html +175 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistInlineFormBlock.tsx.html +124 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistItem.tsx.html +145 -0
- package/src/coverage/lcov-report/src/assistFormComponents/index.html +161 -0
- package/src/coverage/lcov-report/src/assistFormComponents/validation/index.html +131 -0
- package/src/coverage/lcov-report/src/assistFormComponents/validation/listItem.tsx.html +274 -0
- package/src/coverage/lcov-report/src/assistFormComponents/validation/validationList.tsx.html +352 -0
- package/src/coverage/lcov-report/src/assistInspector/AssistInspector.tsx.html +1318 -0
- package/src/coverage/lcov-report/src/assistInspector/FieldAutocomplete.tsx.html +505 -0
- package/src/coverage/lcov-report/src/assistInspector/InstructionTaskHistoryButton.tsx.html +865 -0
- package/src/coverage/lcov-report/src/assistInspector/constants.ts.html +88 -0
- package/src/coverage/lcov-report/src/assistInspector/helpers.ts.html +724 -0
- package/src/coverage/lcov-report/src/assistInspector/index.html +191 -0
- package/src/coverage/lcov-report/src/assistInspector/index.ts.html +163 -0
- package/src/coverage/lcov-report/src/assistLayout/AiAssistanceConfigContext.tsx.html +331 -0
- package/src/coverage/lcov-report/src/assistLayout/AssistLayout.tsx.html +199 -0
- package/src/coverage/lcov-report/src/assistLayout/RunInstructionProvider.tsx.html +751 -0
- package/src/coverage/lcov-report/src/assistLayout/index.html +146 -0
- package/src/coverage/lcov-report/src/components/AssistFeatureBadge.tsx.html +112 -0
- package/src/coverage/lcov-report/src/components/FadeInContent.tsx.html +205 -0
- package/src/coverage/lcov-report/src/components/HideReferenceChangedBannerInput.tsx.html +160 -0
- package/src/coverage/lcov-report/src/components/ImageContext.tsx.html +229 -0
- package/src/coverage/lcov-report/src/components/SafeValueInput.tsx.html +313 -0
- package/src/coverage/lcov-report/src/components/TimeAgo.tsx.html +139 -0
- package/src/coverage/lcov-report/src/components/index.html +191 -0
- package/src/coverage/lcov-report/src/constants.ts.html +145 -0
- package/src/coverage/lcov-report/src/fieldActions/PrivateIcon.tsx.html +145 -0
- package/src/coverage/lcov-report/src/fieldActions/assistFieldActions.tsx.html +907 -0
- package/src/coverage/lcov-report/src/fieldActions/generateCaptionActions.tsx.html +259 -0
- package/src/coverage/lcov-report/src/fieldActions/generateImageActions.tsx.html +256 -0
- package/src/coverage/lcov-report/src/fieldActions/index.html +161 -0
- package/src/coverage/lcov-report/src/helpers/assistSupported.ts.html +226 -0
- package/src/coverage/lcov-report/src/helpers/conditionalMembers.ts.html +466 -0
- package/src/coverage/lcov-report/src/helpers/ids.ts.html +142 -0
- package/src/coverage/lcov-report/src/helpers/index.html +191 -0
- package/src/coverage/lcov-report/src/helpers/misc.ts.html +133 -0
- package/src/coverage/lcov-report/src/helpers/typeUtils.ts.html +208 -0
- package/src/coverage/lcov-report/src/helpers/useAssistSupported.ts.html +106 -0
- package/src/coverage/lcov-report/src/index.html +176 -0
- package/src/coverage/lcov-report/src/index.ts.html +112 -0
- package/src/coverage/lcov-report/src/onboarding/FieldActionsOnboarding.tsx.html +286 -0
- package/src/coverage/lcov-report/src/onboarding/FirstAssistedPathProvider.tsx.html +172 -0
- package/src/coverage/lcov-report/src/onboarding/InspectorOnboarding.tsx.html +223 -0
- package/src/coverage/lcov-report/src/onboarding/index.html +161 -0
- package/src/coverage/lcov-report/src/onboarding/onboardingStore.ts.html +184 -0
- package/src/coverage/lcov-report/src/plugin.tsx.html +427 -0
- package/src/coverage/lcov-report/src/presence/AiFieldPresence.tsx.html +163 -0
- package/src/coverage/lcov-report/src/presence/AssistAvatar.tsx.html +373 -0
- package/src/coverage/lcov-report/src/presence/AssistDocumentPresence.tsx.html +259 -0
- package/src/coverage/lcov-report/src/presence/index.html +161 -0
- package/src/coverage/lcov-report/src/presence/useAssistPresence.ts.html +268 -0
- package/src/coverage/lcov-report/src/schemas/assistDocumentSchema.tsx.html +1552 -0
- package/src/coverage/lcov-report/src/schemas/contextDocumentSchema.tsx.html +253 -0
- package/src/coverage/lcov-report/src/schemas/index.html +176 -0
- package/src/coverage/lcov-report/src/schemas/index.ts.html +277 -0
- package/src/coverage/lcov-report/src/schemas/serialize/SchemTypeTool.tsx.html +391 -0
- package/src/coverage/lcov-report/src/schemas/serialize/index.html +146 -0
- package/src/coverage/lcov-report/src/schemas/serialize/schemaUtils.ts.html +196 -0
- package/src/coverage/lcov-report/src/schemas/serialize/serializeSchema.ts.html +754 -0
- package/src/coverage/lcov-report/src/schemas/serializedSchemaTypeSchema.ts.html +262 -0
- package/src/coverage/lcov-report/src/schemas/typeDefExtensions.ts.html +397 -0
- package/src/coverage/lcov-report/src/translate/FieldTranslationProvider.tsx.html +1003 -0
- package/src/coverage/lcov-report/src/translate/getLanguageParams.ts.html +163 -0
- package/src/coverage/lcov-report/src/translate/index.html +191 -0
- package/src/coverage/lcov-report/src/translate/languageStore.ts.html +139 -0
- package/src/coverage/lcov-report/src/translate/paths.ts.html +577 -0
- package/src/coverage/lcov-report/src/translate/translateActions.tsx.html +637 -0
- package/src/coverage/lcov-report/src/translate/types.ts.html +565 -0
- package/src/coverage/lcov-report/src/types.ts.html +649 -0
- package/src/coverage/lcov-report/src/useApiClient.ts.html +1015 -0
- package/src/coverage/lcov.info +9519 -0
- package/src/coverage/prettify.css +1 -0
- package/src/coverage/prettify.js +2 -0
- package/src/coverage/sort-arrow-sprite.png +0 -0
- package/src/coverage/sorter.js +196 -0
- package/src/coverage/src/_lib/connector/ConnectFromRegion.tsx.html +157 -0
- package/src/coverage/src/_lib/connector/ConnectToRegion.tsx.html +151 -0
- package/src/coverage/src/_lib/connector/ConnectorRegion.tsx.html +154 -0
- package/src/coverage/src/_lib/connector/ConnectorsProvider.tsx.html +142 -0
- package/src/coverage/src/_lib/connector/ConnectorsStore.ts.html +451 -0
- package/src/coverage/src/_lib/connector/ConnectorsStoreContext.ts.html +97 -0
- package/src/coverage/src/_lib/connector/helpers.ts.html +100 -0
- package/src/coverage/src/_lib/connector/index.html +281 -0
- package/src/coverage/src/_lib/connector/index.ts.html +112 -0
- package/src/coverage/src/_lib/connector/mapConnectorToLine.ts.html +334 -0
- package/src/coverage/src/_lib/connector/types.ts.html +253 -0
- package/src/coverage/src/_lib/connector/useConnectorsStore.ts.html +124 -0
- package/src/coverage/src/_lib/connector/useRegionRects.ts.html +508 -0
- package/src/coverage/src/_lib/fixedListenQuery.ts.html +388 -0
- package/src/coverage/src/_lib/form/DocumentForm.tsx.html +676 -0
- package/src/coverage/src/_lib/form/helpers.ts.html +178 -0
- package/src/coverage/src/_lib/form/index.html +146 -0
- package/src/coverage/src/_lib/form/index.ts.html +88 -0
- package/src/coverage/src/_lib/index.html +161 -0
- package/src/coverage/src/_lib/randomKey.ts.html +172 -0
- package/src/coverage/src/_lib/useListeningQuery.ts.html +268 -0
- package/src/coverage/src/_lib/usePrevious.ts.html +112 -0
- package/src/coverage/src/assistConnectors/AssistConnectorsOverlay.tsx.html +481 -0
- package/src/coverage/src/assistConnectors/ConnectorPath.tsx.html +271 -0
- package/src/coverage/src/assistConnectors/draw/arrowPath.ts.html +112 -0
- package/src/coverage/src/assistConnectors/draw/connectorPath.ts.html +511 -0
- package/src/coverage/src/assistConnectors/draw/index.html +131 -0
- package/src/coverage/src/assistConnectors/index.html +146 -0
- package/src/coverage/src/assistConnectors/index.ts.html +88 -0
- package/src/coverage/src/assistDocument/AssistDocumentContext.tsx.html +178 -0
- package/src/coverage/src/assistDocument/AssistDocumentContextProvider.tsx.html +136 -0
- package/src/coverage/src/assistDocument/AssistDocumentInput.tsx.html +280 -0
- package/src/coverage/src/assistDocument/RequestRunInstructionProvider.tsx.html +283 -0
- package/src/coverage/src/assistDocument/components/AssistDocumentForm.tsx.html +775 -0
- package/src/coverage/src/assistDocument/components/FieldRefPreview.tsx.html +166 -0
- package/src/coverage/src/assistDocument/components/InstructionsArrayField.tsx.html +109 -0
- package/src/coverage/src/assistDocument/components/InstructionsArrayInput.tsx.html +163 -0
- package/src/coverage/src/assistDocument/components/SelectedFieldContext.tsx.html +115 -0
- package/src/coverage/src/assistDocument/components/generic/HiddenFieldTitle.tsx.html +100 -0
- package/src/coverage/src/assistDocument/components/generic/index.html +116 -0
- package/src/coverage/src/assistDocument/components/helpers.ts.html +148 -0
- package/src/coverage/src/assistDocument/components/index.html +191 -0
- package/src/coverage/src/assistDocument/components/instruction/BackToInstructionsLink.tsx.html +178 -0
- package/src/coverage/src/assistDocument/components/instruction/FieldRefInput.tsx.html +244 -0
- package/src/coverage/src/assistDocument/components/instruction/InstructionInput.tsx.html +349 -0
- package/src/coverage/src/assistDocument/components/instruction/InstructionOutputField.tsx.html +220 -0
- package/src/coverage/src/assistDocument/components/instruction/InstructionOutputInput.tsx.html +700 -0
- package/src/coverage/src/assistDocument/components/instruction/PromptInput.tsx.html +241 -0
- package/src/coverage/src/assistDocument/components/instruction/appearance/IconInput.tsx.html +223 -0
- package/src/coverage/src/assistDocument/components/instruction/appearance/InstructionVisibility.tsx.html +196 -0
- package/src/coverage/src/assistDocument/components/instruction/appearance/index.html +131 -0
- package/src/coverage/src/assistDocument/components/instruction/index.html +191 -0
- package/src/coverage/src/assistDocument/hooks/index.html +161 -0
- package/src/coverage/src/assistDocument/hooks/useAssistDocumentContextValue.tsx.html +289 -0
- package/src/coverage/src/assistDocument/hooks/useDocumentState.ts.html +103 -0
- package/src/coverage/src/assistDocument/hooks/useInstructionToaster.tsx.html +307 -0
- package/src/coverage/src/assistDocument/hooks/useStudioAssistDocument.ts.html +379 -0
- package/src/coverage/src/assistDocument/index.html +176 -0
- package/src/coverage/src/assistDocument/index.ts.html +88 -0
- package/src/coverage/src/assistFormComponents/AssistField.tsx.html +301 -0
- package/src/coverage/src/assistFormComponents/AssistFormBlock.tsx.html +175 -0
- package/src/coverage/src/assistFormComponents/AssistInlineFormBlock.tsx.html +124 -0
- package/src/coverage/src/assistFormComponents/AssistItem.tsx.html +145 -0
- package/src/coverage/src/assistFormComponents/index.html +161 -0
- package/src/coverage/src/assistFormComponents/validation/index.html +131 -0
- package/src/coverage/src/assistFormComponents/validation/listItem.tsx.html +274 -0
- package/src/coverage/src/assistFormComponents/validation/validationList.tsx.html +352 -0
- package/src/coverage/src/assistInspector/AssistInspector.tsx.html +1318 -0
- package/src/coverage/src/assistInspector/FieldAutocomplete.tsx.html +505 -0
- package/src/coverage/src/assistInspector/InstructionTaskHistoryButton.tsx.html +865 -0
- package/src/coverage/src/assistInspector/constants.ts.html +88 -0
- package/src/coverage/src/assistInspector/helpers.ts.html +724 -0
- package/src/coverage/src/assistInspector/index.html +191 -0
- package/src/coverage/src/assistInspector/index.ts.html +163 -0
- package/src/coverage/src/assistLayout/AiAssistanceConfigContext.tsx.html +331 -0
- package/src/coverage/src/assistLayout/AssistLayout.tsx.html +199 -0
- package/src/coverage/src/assistLayout/RunInstructionProvider.tsx.html +751 -0
- package/src/coverage/src/assistLayout/index.html +146 -0
- package/src/coverage/src/components/AssistFeatureBadge.tsx.html +112 -0
- package/src/coverage/src/components/FadeInContent.tsx.html +205 -0
- package/src/coverage/src/components/HideReferenceChangedBannerInput.tsx.html +160 -0
- package/src/coverage/src/components/ImageContext.tsx.html +229 -0
- package/src/coverage/src/components/SafeValueInput.tsx.html +313 -0
- package/src/coverage/src/components/TimeAgo.tsx.html +139 -0
- package/src/coverage/src/components/index.html +191 -0
- package/src/coverage/src/constants.ts.html +145 -0
- package/src/coverage/src/fieldActions/PrivateIcon.tsx.html +145 -0
- package/src/coverage/src/fieldActions/assistFieldActions.tsx.html +907 -0
- package/src/coverage/src/fieldActions/generateCaptionActions.tsx.html +259 -0
- package/src/coverage/src/fieldActions/generateImageActions.tsx.html +256 -0
- package/src/coverage/src/fieldActions/index.html +161 -0
- package/src/coverage/src/helpers/assistSupported.ts.html +226 -0
- package/src/coverage/src/helpers/conditionalMembers.ts.html +466 -0
- package/src/coverage/src/helpers/ids.ts.html +142 -0
- package/src/coverage/src/helpers/index.html +191 -0
- package/src/coverage/src/helpers/misc.ts.html +133 -0
- package/src/coverage/src/helpers/typeUtils.ts.html +208 -0
- package/src/coverage/src/helpers/useAssistSupported.ts.html +106 -0
- package/src/coverage/src/index.html +176 -0
- package/src/coverage/src/index.ts.html +112 -0
- package/src/coverage/src/onboarding/FieldActionsOnboarding.tsx.html +286 -0
- package/src/coverage/src/onboarding/FirstAssistedPathProvider.tsx.html +172 -0
- package/src/coverage/src/onboarding/InspectorOnboarding.tsx.html +223 -0
- package/src/coverage/src/onboarding/index.html +161 -0
- package/src/coverage/src/onboarding/onboardingStore.ts.html +184 -0
- package/src/coverage/src/plugin.tsx.html +427 -0
- package/src/coverage/src/presence/AiFieldPresence.tsx.html +163 -0
- package/src/coverage/src/presence/AssistAvatar.tsx.html +373 -0
- package/src/coverage/src/presence/AssistDocumentPresence.tsx.html +259 -0
- package/src/coverage/src/presence/index.html +161 -0
- package/src/coverage/src/presence/useAssistPresence.ts.html +268 -0
- package/src/coverage/src/schemas/assistDocumentSchema.tsx.html +1552 -0
- package/src/coverage/src/schemas/contextDocumentSchema.tsx.html +253 -0
- package/src/coverage/src/schemas/index.html +176 -0
- package/src/coverage/src/schemas/index.ts.html +277 -0
- package/src/coverage/src/schemas/serialize/SchemTypeTool.tsx.html +391 -0
- package/src/coverage/src/schemas/serialize/index.html +146 -0
- package/src/coverage/src/schemas/serialize/schemaUtils.ts.html +196 -0
- package/src/coverage/src/schemas/serialize/serializeSchema.ts.html +754 -0
- package/src/coverage/src/schemas/serializedSchemaTypeSchema.ts.html +262 -0
- package/src/coverage/src/schemas/typeDefExtensions.ts.html +397 -0
- package/src/coverage/src/translate/FieldTranslationProvider.tsx.html +1003 -0
- package/src/coverage/src/translate/getLanguageParams.ts.html +163 -0
- package/src/coverage/src/translate/index.html +191 -0
- package/src/coverage/src/translate/languageStore.ts.html +139 -0
- package/src/coverage/src/translate/paths.ts.html +577 -0
- package/src/coverage/src/translate/translateActions.tsx.html +637 -0
- package/src/coverage/src/translate/types.ts.html +565 -0
- package/src/coverage/src/types.ts.html +649 -0
- package/src/coverage/src/useApiClient.ts.html +1015 -0
- package/src/fieldActions/assistFieldActions.tsx +13 -5
- package/src/helpers/assistSupported.ts +6 -13
- package/src/helpers/conditionalMembers.test.ts +200 -0
- package/src/helpers/conditionalMembers.ts +127 -0
- package/src/node_modules/.vitest/deps/_metadata.json +8 -0
- package/src/node_modules/.vitest/deps/package.json +3 -0
- package/src/node_modules/.vitest/results.json +1 -1
- package/src/schemas/serialize/serializeSchema.test.ts +63 -3
- package/src/schemas/serialize/serializeSchema.ts +29 -5
- package/src/translate/FieldTranslationProvider.tsx +4 -1
- package/src/translate/paths.test.ts +45 -0
- package/src/translate/paths.ts +16 -5
- package/src/translate/translateActions.tsx +23 -6
- package/src/types.ts +3 -0
- package/src/useApiClient.ts +11 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- [Disable for a field](#disable-for-a-field)
|
|
17
17
|
- [Disable for an array type](#disable-for-an-array-type)
|
|
18
18
|
- [Unsupported types](#unsupported-types)
|
|
19
|
+
- [Hidden and readOnly fields](#hidden-and-readonly-fields)
|
|
19
20
|
- [Reference support](#reference-support)
|
|
20
21
|
- [Troubleshooting](#troubleshooting)
|
|
21
22
|
- [Included document types](#included-document-types)
|
|
@@ -186,14 +187,25 @@ The following types are not supported, and behave as excluded types:
|
|
|
186
187
|
* [File](https://www.sanity.io/docs/file-type) (never supported, even when file has custom fields)
|
|
187
188
|
* [Reference](https://www.sanity.io/docs/reference-type) (supported when configured with embeddingsIndex)
|
|
188
189
|
|
|
189
|
-
Types and fields with `hidden` or `readonly` with a truthy value (`true` or `function`) are not supported.
|
|
190
|
-
(Hidden and readOnly fields can be referenced in instructions still)
|
|
191
|
-
|
|
192
190
|
Fields with these types will not be changed by the assistant, do not have AI Assist actions, and cannot be referenced in instructions.
|
|
193
191
|
|
|
194
192
|
Objects where all fields are excluded or unsupported and arrays where all member types are excluded or unsupported
|
|
195
193
|
will also be excluded.
|
|
196
194
|
|
|
195
|
+
### Hidden and readOnly fields
|
|
196
|
+
|
|
197
|
+
In AI Assist 2.0 and later, conditionally `hidden` and `readOnly` fields can have instructions.
|
|
198
|
+
These fields can be written to by an instruction, as long as the field is non-hidden and writable when the instruction is started.
|
|
199
|
+
|
|
200
|
+
Fields with `hidden` or `readOnly` set to literal `true` will be skipped by AI Assist.
|
|
201
|
+
|
|
202
|
+
*Note*: An instruction will not re-evaluate these states during a run.
|
|
203
|
+
Ie, if an instructions writes to a field that will make another field in the studio readonly or hidden,
|
|
204
|
+
the running instruction will still consider these as if in their original state.
|
|
205
|
+
|
|
206
|
+
If it is essential that AI Assist *never* writes to a conditional field,
|
|
207
|
+
it should be marked with `options.aiWritingAssistance.exclude: true`.
|
|
208
|
+
|
|
197
209
|
### Reference support
|
|
198
210
|
|
|
199
211
|
#### Create an Embeddings-index
|
package/dist/index.esm.js
CHANGED
|
@@ -153,26 +153,24 @@ function isSchemaAssistEnabled(type) {
|
|
|
153
153
|
return !((_b = (_a = type.options) == null ? void 0 : _a.aiWritingAssistance) == null ? void 0 : _b.exclude);
|
|
154
154
|
}
|
|
155
155
|
function isAssistSupported(type) {
|
|
156
|
-
let allowReadonlyHidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
157
156
|
if (!isSchemaAssistEnabled(type)) {
|
|
158
157
|
return false;
|
|
159
158
|
}
|
|
160
|
-
if (isDisabled(type
|
|
159
|
+
if (isDisabled(type)) {
|
|
161
160
|
return false;
|
|
162
161
|
}
|
|
163
162
|
if (type.jsonType === "array") {
|
|
164
|
-
const unsupportedArray = type.of.every(t => isDisabled(t
|
|
163
|
+
const unsupportedArray = type.of.every(t => isDisabled(t));
|
|
165
164
|
return !unsupportedArray;
|
|
166
165
|
}
|
|
167
166
|
if (type.jsonType === "object") {
|
|
168
|
-
const unsupportedObject = type.fields.every(field => isDisabled(field.type
|
|
167
|
+
const unsupportedObject = type.fields.every(field => isDisabled(field.type));
|
|
169
168
|
return !unsupportedObject;
|
|
170
169
|
}
|
|
171
170
|
return true;
|
|
172
171
|
}
|
|
173
|
-
function isDisabled(type
|
|
174
|
-
|
|
175
|
-
return !isSchemaAssistEnabled(type) || isUnsupportedType(type) || !allowReadonlyHidden && readonlyHidden;
|
|
172
|
+
function isDisabled(type) {
|
|
173
|
+
return !isSchemaAssistEnabled(type) || isUnsupportedType(type);
|
|
176
174
|
}
|
|
177
175
|
function isUnsupportedType(type) {
|
|
178
176
|
var _a, _b;
|
|
@@ -180,7 +178,7 @@ function isUnsupportedType(type) {
|
|
|
180
178
|
}
|
|
181
179
|
const inlineTypes = ["document", "object", "image", "file"];
|
|
182
180
|
function serializeSchema(schema, options) {
|
|
183
|
-
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).
|
|
181
|
+
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).map(t => getSchemaStub(t, schema, options)).filter(t => {
|
|
184
182
|
if ("to" in t && t.to && !t.to.length) {
|
|
185
183
|
return false;
|
|
186
184
|
}
|
|
@@ -233,14 +231,26 @@ function getBaseFields(schema, type, typeName, options) {
|
|
|
233
231
|
to: "to" in type && typeName === "reference" ? refToTypeNames(type) : void 0,
|
|
234
232
|
fields: "fields" in type && inlineTypes.includes(typeName) ? serializeFields(schema, type, options) : void 0,
|
|
235
233
|
annotations: typeName === "block" && "fields" in type ? serializeAnnotations(type, schema, options) : void 0,
|
|
236
|
-
inlineOf: typeName === "block" && "fields" in type ? serializeInlineOf(type, schema, options) : void 0
|
|
234
|
+
inlineOf: typeName === "block" && "fields" in type ? serializeInlineOf(type, schema, options) : void 0,
|
|
235
|
+
hidden: typeof type.hidden === "function" ? "function" : type.hidden ? true : void 0,
|
|
236
|
+
readOnly: typeof type.readOnly === "function" ? "function" : type.readOnly ? true : void 0
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
function serializeFields(schema, schemaType, options) {
|
|
240
|
-
|
|
240
|
+
const fields = schemaType.fieldsets ? schemaType.fieldsets.flatMap(fs => fs.single ? fs.field : fs.fields.map(f => ({
|
|
241
|
+
...f,
|
|
242
|
+
type: {
|
|
243
|
+
...f.type,
|
|
244
|
+
// if fieldset is (conditionally) hidden, the field must be considered the same way
|
|
245
|
+
// ie, if the field does not show up in conditionalMembers, it is hidden
|
|
246
|
+
// regardless of weather or not it is the field function or the fieldset function that hides it
|
|
247
|
+
hidden: typeof fs.hidden === "function" ? fs.hidden : fs.hidden ? true : f.type.hidden
|
|
248
|
+
}
|
|
249
|
+
}))) : schemaType.fields;
|
|
250
|
+
return fields.filter(f => {
|
|
241
251
|
var _a, _b;
|
|
242
252
|
return !["sanity.imageHotspot", "sanity.imageCrop"].includes((_b = (_a = f.type) == null ? void 0 : _a.name) != null ? _b : "");
|
|
243
|
-
}).filter(f => isAssistSupported(f.type)).
|
|
253
|
+
}).filter(f => isAssistSupported(f.type)).map(field => serializeMember(schema, field.type, field.name, options));
|
|
244
254
|
}
|
|
245
255
|
function serializeMember(schema, type, name, options) {
|
|
246
256
|
var _a, _b;
|
|
@@ -393,13 +403,13 @@ function SchemaEntry(_ref) {
|
|
|
393
403
|
children: out
|
|
394
404
|
});
|
|
395
405
|
}
|
|
396
|
-
const MAX_DEPTH = 6;
|
|
406
|
+
const MAX_DEPTH$1 = 6;
|
|
397
407
|
function getDocumentMembersFlat(doc, schemaType) {
|
|
398
408
|
if (!isDocumentSchemaType(schemaType)) {
|
|
399
409
|
console.error("Schema type is not a document");
|
|
400
410
|
return [];
|
|
401
411
|
}
|
|
402
|
-
return extractPaths(doc, schemaType, [], MAX_DEPTH);
|
|
412
|
+
return extractPaths(doc, schemaType, [], MAX_DEPTH$1);
|
|
403
413
|
}
|
|
404
414
|
function extractPaths(doc, schemaType, path, maxDepth) {
|
|
405
415
|
if (path.length >= maxDepth) {
|
|
@@ -431,16 +441,24 @@ function extractPaths(doc, schemaType, path, maxDepth) {
|
|
|
431
441
|
let arrayPaths = [];
|
|
432
442
|
if (arrayValue == null ? void 0 : arrayValue.length) {
|
|
433
443
|
for (const item of arrayValue) {
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
444
|
+
const itemPath = [...fieldPath, {
|
|
445
|
+
_key: item._key
|
|
446
|
+
}];
|
|
447
|
+
let itemSchema = fieldSchema.of.find(t => t.name === item._type);
|
|
448
|
+
if (!item._type) {
|
|
449
|
+
itemSchema = fieldSchema.of[0];
|
|
450
|
+
console.warn("Array item is missing _type - using the first defined type in the array.of schema", {
|
|
451
|
+
itemPath,
|
|
452
|
+
item,
|
|
453
|
+
itemSchema
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (item._key && itemSchema) {
|
|
457
|
+
const innerFields = extractPaths(doc, itemSchema, itemPath, maxDepth);
|
|
440
458
|
const arrayMember = {
|
|
441
459
|
path: itemPath,
|
|
442
460
|
name: item._key,
|
|
443
|
-
schemaType:
|
|
461
|
+
schemaType: itemSchema,
|
|
444
462
|
value: item
|
|
445
463
|
};
|
|
446
464
|
arrayPaths = [...arrayPaths, arrayMember, ...innerFields];
|
|
@@ -682,7 +700,7 @@ function getFieldRefs(schemaType, parent) {
|
|
|
682
700
|
};
|
|
683
701
|
const fields = field.type.jsonType === "object" ? getFieldRefs(field.type, fieldRef, depth + 1) : [];
|
|
684
702
|
const syntheticFields = field.type.jsonType === "array" ? getSyntheticFields(field.type, fieldRef, depth + 1) : [];
|
|
685
|
-
if (!isAssistSupported(field.type
|
|
703
|
+
if (!isAssistSupported(field.type)) {
|
|
686
704
|
return [...fields, ...syntheticFields];
|
|
687
705
|
}
|
|
688
706
|
return [fieldRef, ...fields, ...syntheticFields];
|
|
@@ -709,7 +727,7 @@ function getSyntheticFields(schemaType, parent) {
|
|
|
709
727
|
synthetic: true
|
|
710
728
|
};
|
|
711
729
|
const fields = itemType.jsonType === "object" ? getFieldRefs(itemType, fieldRef, depth + 1) : [];
|
|
712
|
-
if (!isAssistSupported(itemType
|
|
730
|
+
if (!isAssistSupported(itemType)) {
|
|
713
731
|
return fields;
|
|
714
732
|
}
|
|
715
733
|
return [fieldRef, ...fields];
|
|
@@ -1099,7 +1117,8 @@ function useTranslate(apiClient) {
|
|
|
1099
1117
|
documentId,
|
|
1100
1118
|
languagePath,
|
|
1101
1119
|
translatePath,
|
|
1102
|
-
fieldLanguageMap
|
|
1120
|
+
fieldLanguageMap,
|
|
1121
|
+
conditionalMembers
|
|
1103
1122
|
} = _ref4;
|
|
1104
1123
|
setLoading(true);
|
|
1105
1124
|
return apiClient.request({
|
|
@@ -1110,6 +1129,7 @@ function useTranslate(apiClient) {
|
|
|
1110
1129
|
types,
|
|
1111
1130
|
languagePath,
|
|
1112
1131
|
fieldLanguageMap,
|
|
1132
|
+
conditionalMembers,
|
|
1113
1133
|
translatePath: translatePath.length === 0 ? documentRootKey : pathToString(translatePath),
|
|
1114
1134
|
userId: user == null ? void 0 : user.id
|
|
1115
1135
|
}
|
|
@@ -1962,6 +1982,78 @@ function FieldTitle(props) {
|
|
|
1962
1982
|
})
|
|
1963
1983
|
});
|
|
1964
1984
|
}
|
|
1985
|
+
const MAX_DEPTH = 8;
|
|
1986
|
+
function getConditionalMembers(docState) {
|
|
1987
|
+
const doc = {
|
|
1988
|
+
path: "",
|
|
1989
|
+
hidden: false,
|
|
1990
|
+
readOnly: !!docState.readOnly,
|
|
1991
|
+
conditional: typeof docState.schemaType.hidden === "function"
|
|
1992
|
+
};
|
|
1993
|
+
return [doc, ...extractConditionalPaths(docState, MAX_DEPTH)].filter(v => v.conditional).map(_ref10 => {
|
|
1994
|
+
let {
|
|
1995
|
+
conditional,
|
|
1996
|
+
...state
|
|
1997
|
+
} = _ref10;
|
|
1998
|
+
return {
|
|
1999
|
+
...state
|
|
2000
|
+
};
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
function isConditional(schemaType) {
|
|
2004
|
+
return typeof schemaType.hidden === "function" || typeof schemaType.readOnly === "function";
|
|
2005
|
+
}
|
|
2006
|
+
function conditionalState(memberState) {
|
|
2007
|
+
return {
|
|
2008
|
+
path: pathToString(memberState.path),
|
|
2009
|
+
readOnly: !!memberState.readOnly,
|
|
2010
|
+
hidden: false,
|
|
2011
|
+
// if its in members, its not hidden
|
|
2012
|
+
conditional: isConditional(memberState.schemaType)
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
function extractConditionalPaths(node, maxDepth) {
|
|
2016
|
+
if (node.path.length >= maxDepth) {
|
|
2017
|
+
return [];
|
|
2018
|
+
}
|
|
2019
|
+
return node.members.reduce((acc, member) => {
|
|
2020
|
+
var _a, _b;
|
|
2021
|
+
if (member.kind === "error") {
|
|
2022
|
+
return acc;
|
|
2023
|
+
}
|
|
2024
|
+
if (member.kind === "field") {
|
|
2025
|
+
const schemaType = member.field.schemaType;
|
|
2026
|
+
if (schemaType.jsonType === "object") {
|
|
2027
|
+
const innerFields = member.field.readOnly ? [] : extractConditionalPaths(member.field, maxDepth);
|
|
2028
|
+
return [...acc, conditionalState(member.field), ...innerFields];
|
|
2029
|
+
} else if (schemaType.jsonType === "array") {
|
|
2030
|
+
const array = member.field;
|
|
2031
|
+
let arrayPaths = [];
|
|
2032
|
+
const isObjectsArray = array.members.some(m => m.kind === "item" && isObjectSchemaType(m.item.schemaType));
|
|
2033
|
+
if (!array.readOnly) {
|
|
2034
|
+
for (const arrayMember of array.members) {
|
|
2035
|
+
if (arrayMember.kind === "error") {
|
|
2036
|
+
continue;
|
|
2037
|
+
}
|
|
2038
|
+
const innerFields = isObjectsArray && !arrayMember.item.readOnly ? extractConditionalPaths(arrayMember.item, maxDepth) : [];
|
|
2039
|
+
arrayPaths = [...arrayPaths, conditionalState(arrayMember.item), ...innerFields];
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
return [...acc, conditionalState(array), ...arrayPaths];
|
|
2043
|
+
}
|
|
2044
|
+
return [...acc, conditionalState(member.field)];
|
|
2045
|
+
} else if (member.kind === "fieldSet") {
|
|
2046
|
+
const conditionalFieldset = !!((_b = (_a = node.schemaType) == null ? void 0 : _a.fieldsets) == null ? void 0 : _b.some(f => !f.single && f.name === member.fieldSet.name && typeof f.hidden === "function"));
|
|
2047
|
+
const innerFields = extractConditionalPaths(member.fieldSet, maxDepth).map(f => ({
|
|
2048
|
+
...f,
|
|
2049
|
+
// if fieldset is conditional, visible fields must also be considered conditional
|
|
2050
|
+
conditional: conditionalFieldset != null ? conditionalFieldset : f.conditional
|
|
2051
|
+
}));
|
|
2052
|
+
return [...acc, ...innerFields];
|
|
2053
|
+
}
|
|
2054
|
+
return acc;
|
|
2055
|
+
}, []);
|
|
2056
|
+
}
|
|
1965
2057
|
var __freeze$4 = Object.freeze;
|
|
1966
2058
|
var __defProp$4 = Object.defineProperty;
|
|
1967
2059
|
var __template$4 = (cooked, raw) => __freeze$4(__defProp$4(cooked, "raw", {
|
|
@@ -2101,12 +2193,15 @@ function AssistInspector(props) {
|
|
|
2101
2193
|
documentType,
|
|
2102
2194
|
value: docValue,
|
|
2103
2195
|
schemaType,
|
|
2104
|
-
onChange: documentOnChange
|
|
2196
|
+
onChange: documentOnChange,
|
|
2197
|
+
formState
|
|
2105
2198
|
} = documentPane;
|
|
2106
2199
|
const {
|
|
2107
2200
|
published,
|
|
2108
2201
|
draft
|
|
2109
2202
|
} = useEditState(documentId, documentType, "low");
|
|
2203
|
+
const formStateRef = useRef(formState);
|
|
2204
|
+
formStateRef.current = formState;
|
|
2110
2205
|
const assistableDocId = getAssistableDocId(schemaType, documentId);
|
|
2111
2206
|
const {
|
|
2112
2207
|
instructionLoading,
|
|
@@ -2160,7 +2255,8 @@ function AssistInspector(props) {
|
|
|
2160
2255
|
path: pathKey,
|
|
2161
2256
|
typePath,
|
|
2162
2257
|
assistDocumentId: assistDocumentId(documentType),
|
|
2163
|
-
instruction
|
|
2258
|
+
instruction,
|
|
2259
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
2164
2260
|
}), [pathKey, instruction, typePath, documentType, assistableDocId, requestRunInstruction]);
|
|
2165
2261
|
const Region = useCallback(_props => {
|
|
2166
2262
|
return /* @__PURE__ */jsx("div", {
|
|
@@ -2346,10 +2442,10 @@ const assistInspector = {
|
|
|
2346
2442
|
showAsAction: false
|
|
2347
2443
|
}),
|
|
2348
2444
|
component: AssistInspectorWrapper,
|
|
2349
|
-
onClose(
|
|
2445
|
+
onClose(_ref11) {
|
|
2350
2446
|
let {
|
|
2351
2447
|
params
|
|
2352
|
-
} =
|
|
2448
|
+
} = _ref11;
|
|
2353
2449
|
return {
|
|
2354
2450
|
params: typed({
|
|
2355
2451
|
...params,
|
|
@@ -2422,11 +2518,11 @@ var __template$3 = (cooked, raw) => __freeze$3(__defProp$3(cooked, "raw", {
|
|
|
2422
2518
|
var _a$3, _b$1;
|
|
2423
2519
|
const fadeIn = keyframes(_a$3 || (_a$3 = __template$3(["\n 0% {\n opacity: 0;\n transform: scale(0.75);\n }\n 40% {\n opacity: 0;\n transform: scale(0.75);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n"])));
|
|
2424
2520
|
const FadeInDiv = styled.div(_b$1 || (_b$1 = __template$3(["\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n"])), fadeIn);
|
|
2425
|
-
const FadeInContent = forwardRef(function FadeInContent2(
|
|
2521
|
+
const FadeInContent = forwardRef(function FadeInContent2(_ref12, ref) {
|
|
2426
2522
|
let {
|
|
2427
2523
|
children,
|
|
2428
2524
|
durationMs = 250
|
|
2429
|
-
} =
|
|
2525
|
+
} = _ref12;
|
|
2430
2526
|
return /* @__PURE__ */jsx(FadeInDiv, {
|
|
2431
2527
|
ref,
|
|
2432
2528
|
style: {
|
|
@@ -4509,12 +4605,13 @@ function FieldTranslationProvider(props) {
|
|
|
4509
4605
|
if (fieldLanguageMaps && documentId && translatePath) {
|
|
4510
4606
|
runTranslate({
|
|
4511
4607
|
documentId,
|
|
4512
|
-
translatePath
|
|
4608
|
+
translatePath,
|
|
4513
4609
|
fieldLanguageMap: fieldLanguageMaps.map(map => ({
|
|
4514
4610
|
...map,
|
|
4515
4611
|
// eslint-disable-next-line max-nested-callbacks
|
|
4516
4612
|
outputs: map.outputs.filter(out => !!(toLanguages == null ? void 0 : toLanguages.find(l => l.id === out.id)))
|
|
4517
|
-
}))
|
|
4613
|
+
})),
|
|
4614
|
+
conditionalMembers: fieldTranslationParams == null ? void 0 : fieldTranslationParams.conditionalMembers
|
|
4518
4615
|
});
|
|
4519
4616
|
}
|
|
4520
4617
|
close();
|
|
@@ -4805,11 +4902,11 @@ function InstructionInput(props) {
|
|
|
4805
4902
|
})]
|
|
4806
4903
|
});
|
|
4807
4904
|
}
|
|
4808
|
-
function ObjectMember(
|
|
4905
|
+
function ObjectMember(_ref13) {
|
|
4809
4906
|
let {
|
|
4810
4907
|
fieldName,
|
|
4811
4908
|
...props
|
|
4812
|
-
} =
|
|
4909
|
+
} = _ref13;
|
|
4813
4910
|
const member = findFieldMember(props.members, fieldName);
|
|
4814
4911
|
return member ? /* @__PURE__ */jsx(ObjectInputMember, {
|
|
4815
4912
|
...props,
|
|
@@ -4948,8 +5045,8 @@ function IconInput(props) {
|
|
|
4948
5045
|
onChange
|
|
4949
5046
|
} = props;
|
|
4950
5047
|
const id = useId();
|
|
4951
|
-
const items = useMemo(() => Object.entries(icons).map(
|
|
4952
|
-
let [key, icon] =
|
|
5048
|
+
const items = useMemo(() => Object.entries(icons).map(_ref14 => {
|
|
5049
|
+
let [key, icon] = _ref14;
|
|
4953
5050
|
return /* @__PURE__ */jsx(IconItem, {
|
|
4954
5051
|
iconKey: key,
|
|
4955
5052
|
icon,
|
|
@@ -4977,12 +5074,12 @@ function IconInput(props) {
|
|
|
4977
5074
|
}
|
|
4978
5075
|
});
|
|
4979
5076
|
}
|
|
4980
|
-
function IconItem(
|
|
5077
|
+
function IconItem(_ref15) {
|
|
4981
5078
|
let {
|
|
4982
5079
|
icon,
|
|
4983
5080
|
iconKey: key,
|
|
4984
5081
|
onChange
|
|
4985
|
-
} =
|
|
5082
|
+
} = _ref15;
|
|
4986
5083
|
const onClick = useCallback(() => onChange(set(key)), [onChange, key]);
|
|
4987
5084
|
return /* @__PURE__ */jsx(MenuItem, {
|
|
4988
5085
|
icon,
|
|
@@ -4993,8 +5090,8 @@ function IconItem(_ref14) {
|
|
|
4993
5090
|
}
|
|
4994
5091
|
function getIcon(iconName) {
|
|
4995
5092
|
var _a, _b;
|
|
4996
|
-
return (_b = (_a = Object.entries(icons).find(
|
|
4997
|
-
let [key] =
|
|
5093
|
+
return (_b = (_a = Object.entries(icons).find(_ref16 => {
|
|
5094
|
+
let [key] = _ref16;
|
|
4998
5095
|
return key === iconName;
|
|
4999
5096
|
})) == null ? void 0 : _a[1]) != null ? _b : icons.sparkles;
|
|
5000
5097
|
}
|
|
@@ -5153,11 +5250,11 @@ const contextDocumentSchema = defineType({
|
|
|
5153
5250
|
title: "title",
|
|
5154
5251
|
context: "context"
|
|
5155
5252
|
},
|
|
5156
|
-
prepare(
|
|
5253
|
+
prepare(_ref17) {
|
|
5157
5254
|
let {
|
|
5158
5255
|
title,
|
|
5159
5256
|
context
|
|
5160
|
-
} =
|
|
5257
|
+
} = _ref17;
|
|
5161
5258
|
var _a;
|
|
5162
5259
|
const text = context == null ? void 0 : context.flatMap(block => block == null ? void 0 : block.children).flatMap(child => {
|
|
5163
5260
|
var _a2;
|
|
@@ -5257,11 +5354,11 @@ function InstructionOutputField(props) {
|
|
|
5257
5354
|
children: props.children
|
|
5258
5355
|
});
|
|
5259
5356
|
}
|
|
5260
|
-
function EnabledOutputField(
|
|
5357
|
+
function EnabledOutputField(_ref18) {
|
|
5261
5358
|
let {
|
|
5262
5359
|
fieldSchema,
|
|
5263
5360
|
...props
|
|
5264
|
-
} =
|
|
5361
|
+
} = _ref18;
|
|
5265
5362
|
var _a;
|
|
5266
5363
|
const [open, setOpen] = useState(!!((_a = props.value) == null ? void 0 : _a.length));
|
|
5267
5364
|
const onExpand = useCallback(() => setOpen(true), []);
|
|
@@ -5309,11 +5406,11 @@ function useEmptySelectAllValue(value, allowedValues, onChange) {
|
|
|
5309
5406
|
}
|
|
5310
5407
|
}, [allowedValues, value, onChange]);
|
|
5311
5408
|
}
|
|
5312
|
-
function ObjectOutputInput(
|
|
5409
|
+
function ObjectOutputInput(_ref19) {
|
|
5313
5410
|
let {
|
|
5314
5411
|
fieldSchema,
|
|
5315
5412
|
...props
|
|
5316
|
-
} =
|
|
5413
|
+
} = _ref19;
|
|
5317
5414
|
const {
|
|
5318
5415
|
value,
|
|
5319
5416
|
onChange
|
|
@@ -5360,11 +5457,11 @@ function ObjectOutputInput(_ref18) {
|
|
|
5360
5457
|
})
|
|
5361
5458
|
});
|
|
5362
5459
|
}
|
|
5363
|
-
function ArrayOutputInput(
|
|
5460
|
+
function ArrayOutputInput(_ref20) {
|
|
5364
5461
|
let {
|
|
5365
5462
|
fieldSchema,
|
|
5366
5463
|
...props
|
|
5367
|
-
} =
|
|
5464
|
+
} = _ref20;
|
|
5368
5465
|
const {
|
|
5369
5466
|
value,
|
|
5370
5467
|
onChange
|
|
@@ -5409,13 +5506,13 @@ function ArrayOutputInput(_ref19) {
|
|
|
5409
5506
|
})
|
|
5410
5507
|
});
|
|
5411
5508
|
}
|
|
5412
|
-
function Selectable(
|
|
5509
|
+
function Selectable(_ref21) {
|
|
5413
5510
|
let {
|
|
5414
5511
|
title,
|
|
5415
5512
|
arrayValue,
|
|
5416
5513
|
value,
|
|
5417
5514
|
onChange
|
|
5418
|
-
} =
|
|
5515
|
+
} = _ref21;
|
|
5419
5516
|
const checked = !(arrayValue == null ? void 0 : arrayValue.length) || !!(arrayValue == null ? void 0 : arrayValue.find(v => v._key === value));
|
|
5420
5517
|
const handleChange = useCallback(() => onChange(checked, value), [onChange, checked, value]);
|
|
5421
5518
|
return /* @__PURE__ */jsxs(Flex, {
|
|
@@ -5480,10 +5577,10 @@ const fieldReference = defineType({
|
|
|
5480
5577
|
select: {
|
|
5481
5578
|
path: "path"
|
|
5482
5579
|
},
|
|
5483
|
-
prepare(
|
|
5580
|
+
prepare(_ref22) {
|
|
5484
5581
|
let {
|
|
5485
5582
|
path
|
|
5486
|
-
} =
|
|
5583
|
+
} = _ref22;
|
|
5487
5584
|
return {
|
|
5488
5585
|
title: path,
|
|
5489
5586
|
path,
|
|
@@ -5628,12 +5725,12 @@ const instruction = defineType({
|
|
|
5628
5725
|
title: "title",
|
|
5629
5726
|
userId: "userId"
|
|
5630
5727
|
},
|
|
5631
|
-
prepare:
|
|
5728
|
+
prepare: _ref23 => {
|
|
5632
5729
|
let {
|
|
5633
5730
|
icon,
|
|
5634
5731
|
title,
|
|
5635
5732
|
userId
|
|
5636
|
-
} =
|
|
5733
|
+
} = _ref23;
|
|
5637
5734
|
return {
|
|
5638
5735
|
title,
|
|
5639
5736
|
icon: icon ? icons[icon] : SparklesIcon,
|
|
@@ -6089,7 +6186,8 @@ const translateActions = {
|
|
|
6089
6186
|
useAction(props) {
|
|
6090
6187
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6091
6188
|
const {
|
|
6092
|
-
config
|
|
6189
|
+
config,
|
|
6190
|
+
status
|
|
6093
6191
|
} = useAiAssistanceConfig();
|
|
6094
6192
|
const apiClient = useApiClient(config == null ? void 0 : config.__customApiClient);
|
|
6095
6193
|
const {
|
|
@@ -6100,24 +6198,28 @@ const translateActions = {
|
|
|
6100
6198
|
documentIsAssistable
|
|
6101
6199
|
} = props;
|
|
6102
6200
|
const isDocumentLevel = path.length === 0;
|
|
6201
|
+
const readOnly = fieldSchemaType.readOnly === true;
|
|
6103
6202
|
const docTransTypes = (_b = (_a = config.translate) == null ? void 0 : _a.document) == null ? void 0 : _b.documentTypes;
|
|
6104
6203
|
const options = fieldSchemaType == null ? void 0 : fieldSchemaType.options;
|
|
6105
6204
|
const addFieldAction = isDocumentLevel || ((_c = options == null ? void 0 : options.aiWritingAssistance) == null ? void 0 : _c.translateAction);
|
|
6106
|
-
const fieldTransEnabled = addFieldAction && documentSchemaType && ((_f = (_e = (_d = config.translate) == null ? void 0 : _d.field) == null ? void 0 : _e.documentTypes) == null ? void 0 : _f.includes(documentSchemaType.name));
|
|
6107
|
-
const documentTranslationEnabled = addFieldAction && documentSchemaType && (!docTransTypes && isAssistSupported(fieldSchemaType) || (docTransTypes == null ? void 0 : docTransTypes.includes(documentSchemaType.name)));
|
|
6205
|
+
const fieldTransEnabled = addFieldAction && (status == null ? void 0 : status.initialized) && documentSchemaType && ((_f = (_e = (_d = config.translate) == null ? void 0 : _d.field) == null ? void 0 : _e.documentTypes) == null ? void 0 : _f.includes(documentSchemaType.name));
|
|
6206
|
+
const documentTranslationEnabled = addFieldAction && (status == null ? void 0 : status.initialized) && documentSchemaType && (!docTransTypes && isAssistSupported(fieldSchemaType) || (docTransTypes == null ? void 0 : docTransTypes.includes(documentSchemaType.name)));
|
|
6108
6207
|
if (documentSchemaType && (documentTranslationEnabled || fieldTransEnabled)) {
|
|
6109
6208
|
const {
|
|
6110
6209
|
value: documentValue,
|
|
6111
|
-
onChange: documentOnChange
|
|
6210
|
+
onChange: documentOnChange,
|
|
6211
|
+
formState
|
|
6112
6212
|
} = useDocumentPane();
|
|
6113
6213
|
const docRef = useRef(documentValue);
|
|
6214
|
+
docRef.current = documentValue;
|
|
6215
|
+
const formStateRef = useRef(formState);
|
|
6216
|
+
formStateRef.current = formState;
|
|
6114
6217
|
const translationApi = useTranslate(apiClient);
|
|
6115
6218
|
const translate = useDraftDelayedTask({
|
|
6116
6219
|
documentOnChange,
|
|
6117
6220
|
isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false,
|
|
6118
6221
|
task: translationApi.translate
|
|
6119
6222
|
});
|
|
6120
|
-
docRef.current = documentValue;
|
|
6121
6223
|
const languagePath = (_h = (_g = config.translate) == null ? void 0 : _g.document) == null ? void 0 : _h.languageField;
|
|
6122
6224
|
const translateDocumentAction = useMemo(() => {
|
|
6123
6225
|
if (!languagePath || !documentTranslationEnabled) {
|
|
@@ -6144,13 +6246,14 @@ const translateActions = {
|
|
|
6144
6246
|
translate({
|
|
6145
6247
|
languagePath,
|
|
6146
6248
|
translatePath: path,
|
|
6147
|
-
documentId: documentId != null ? documentId : ""
|
|
6249
|
+
documentId: documentId != null ? documentId : "",
|
|
6250
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
6148
6251
|
});
|
|
6149
6252
|
},
|
|
6150
6253
|
renderAsButton: true,
|
|
6151
|
-
disabled: translationApi.loading
|
|
6254
|
+
disabled: translationApi.loading || readOnly
|
|
6152
6255
|
});
|
|
6153
|
-
}, [languagePath, translate, documentId, translationApi.loading, documentTranslationEnabled, path]);
|
|
6256
|
+
}, [languagePath, translate, documentId, translationApi.loading, documentTranslationEnabled, path, readOnly]);
|
|
6154
6257
|
const fieldTranslate = useFieldTranslation();
|
|
6155
6258
|
const openFieldTranslation = useDraftDelayedTask({
|
|
6156
6259
|
documentOnChange,
|
|
@@ -6174,15 +6277,19 @@ const translateActions = {
|
|
|
6174
6277
|
if (fieldTranslate.translationLoading || !documentId) {
|
|
6175
6278
|
return;
|
|
6176
6279
|
}
|
|
6280
|
+
if (formStateRef.current) {
|
|
6281
|
+
getConditionalMembers(formStateRef.current);
|
|
6282
|
+
}
|
|
6177
6283
|
openFieldTranslation({
|
|
6178
6284
|
document: docRef.current,
|
|
6179
6285
|
documentSchema: documentSchemaType,
|
|
6180
|
-
translatePath: path
|
|
6286
|
+
translatePath: path,
|
|
6287
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
6181
6288
|
});
|
|
6182
6289
|
},
|
|
6183
6290
|
renderAsButton: true,
|
|
6184
|
-
disabled: fieldTranslate.translationLoading
|
|
6185
|
-
}) : void 0, [openFieldTranslation, documentSchemaType, documentId, fieldTranslate.translationLoading, fieldTransEnabled, path]);
|
|
6291
|
+
disabled: fieldTranslate.translationLoading || readOnly
|
|
6292
|
+
}) : void 0, [openFieldTranslation, documentSchemaType, documentId, fieldTranslate.translationLoading, fieldTransEnabled, path, readOnly]);
|
|
6186
6293
|
return useMemo(() => {
|
|
6187
6294
|
return node$2({
|
|
6188
6295
|
type: "group",
|
|
@@ -6278,8 +6385,11 @@ const assistFieldActions = {
|
|
|
6278
6385
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6279
6386
|
useAssistDocumentContext();
|
|
6280
6387
|
const {
|
|
6281
|
-
value: docValue
|
|
6388
|
+
value: docValue,
|
|
6389
|
+
formState
|
|
6282
6390
|
} = useDocumentPane();
|
|
6391
|
+
const formStateRef = useRef(formState);
|
|
6392
|
+
formStateRef.current = formState;
|
|
6283
6393
|
const currentUser = useCurrentUser();
|
|
6284
6394
|
const isHidden = !assistDocument;
|
|
6285
6395
|
const pathKey = usePathKey(props.path);
|
|
@@ -6293,7 +6403,7 @@ const assistFieldActions = {
|
|
|
6293
6403
|
isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false
|
|
6294
6404
|
});
|
|
6295
6405
|
const isSelectable = !!useSelectedField(documentSchemaType, typePath);
|
|
6296
|
-
const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType);
|
|
6406
|
+
const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType) && schemaType.readOnly !== true;
|
|
6297
6407
|
const fieldAssist = useMemo(() => {
|
|
6298
6408
|
var _a;
|
|
6299
6409
|
return ((_a = assistDocument == null ? void 0 : assistDocument.fields) != null ? _a : []).find(f => f.path === typePath || pathKey === documentRootKey && f.path === pathKey);
|
|
@@ -6323,7 +6433,8 @@ const assistFieldActions = {
|
|
|
6323
6433
|
assistDocumentId,
|
|
6324
6434
|
path: pathKey,
|
|
6325
6435
|
typePath,
|
|
6326
|
-
instruction
|
|
6436
|
+
instruction,
|
|
6437
|
+
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
6327
6438
|
});
|
|
6328
6439
|
}, [requestRunInstruction, assistableDocId, pathKey, typePath, assistDocumentId, fieldAssistKey]);
|
|
6329
6440
|
const privateInstructions = useMemo(() => {
|
|
@@ -6399,9 +6510,7 @@ function instructionItem(props) {
|
|
|
6399
6510
|
iconRight: isPrivate ? PrivateIcon : void 0,
|
|
6400
6511
|
title: getInstructionTitle(instruction),
|
|
6401
6512
|
onAction: () => onInstructionAction(instruction),
|
|
6402
|
-
disabled: assistSupported
|
|
6403
|
-
reason: "".concat(pluginTitle, " is not supported for this field")
|
|
6404
|
-
},
|
|
6513
|
+
disabled: !assistSupported,
|
|
6405
6514
|
hidden
|
|
6406
6515
|
});
|
|
6407
6516
|
}
|
|
@@ -6492,11 +6601,11 @@ function AssistDocumentInputWrapper(props) {
|
|
|
6492
6601
|
documentId
|
|
6493
6602
|
});
|
|
6494
6603
|
}
|
|
6495
|
-
function AssistDocumentInput(
|
|
6604
|
+
function AssistDocumentInput(_ref24) {
|
|
6496
6605
|
let {
|
|
6497
6606
|
documentId,
|
|
6498
6607
|
...props
|
|
6499
|
-
} =
|
|
6608
|
+
} = _ref24;
|
|
6500
6609
|
useInstructionToaster(documentId, props.schemaType);
|
|
6501
6610
|
const schemaType = useMemo(() => {
|
|
6502
6611
|
if (props.schemaType.name !== assistDocumentTypeName) {
|
|
@@ -6602,11 +6711,11 @@ const assist = definePlugin(config => {
|
|
|
6602
6711
|
}
|
|
6603
6712
|
return prev;
|
|
6604
6713
|
},
|
|
6605
|
-
unstable_fieldActions: (prev,
|
|
6714
|
+
unstable_fieldActions: (prev, _ref25) => {
|
|
6606
6715
|
let {
|
|
6607
6716
|
documentType,
|
|
6608
6717
|
schema
|
|
6609
|
-
} =
|
|
6718
|
+
} = _ref25;
|
|
6610
6719
|
if (documentType === assistDocumentTypeName) {
|
|
6611
6720
|
return [];
|
|
6612
6721
|
}
|
|
@@ -6616,12 +6725,12 @@ const assist = definePlugin(config => {
|
|
|
6616
6725
|
}
|
|
6617
6726
|
return prev;
|
|
6618
6727
|
},
|
|
6619
|
-
unstable_languageFilter: (prev,
|
|
6728
|
+
unstable_languageFilter: (prev, _ref26) => {
|
|
6620
6729
|
let {
|
|
6621
6730
|
documentId,
|
|
6622
6731
|
schema,
|
|
6623
6732
|
schemaType
|
|
6624
|
-
} =
|
|
6733
|
+
} = _ref26;
|
|
6625
6734
|
if (schemaType === assistDocumentTypeName) {
|
|
6626
6735
|
return [];
|
|
6627
6736
|
}
|