@flowgram.ai/form-materials 0.4.6 → 0.4.8
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/dist/esm/{chunk-6OZSB6PD.js → chunk-727SU246.js} +6 -3
- package/dist/esm/chunk-727SU246.js.map +1 -0
- package/dist/esm/{chunk-QIJ4QVB2.js → chunk-DEZUEMUM.js} +17 -4
- package/dist/esm/chunk-DEZUEMUM.js.map +1 -0
- package/dist/esm/{chunk-G4HQ7OSI.js → chunk-IHOHRV5V.js} +67 -30
- package/dist/esm/chunk-IHOHRV5V.js.map +1 -0
- package/dist/esm/{editor-H2R7JJLO.js → editor-4X7K477H.js} +4 -4
- package/dist/esm/editor-4X7K477H.js.map +1 -0
- package/dist/esm/{editor-YMNCDGUR.js → editor-OXPGKPF5.js} +4 -4
- package/dist/esm/editor-OXPGKPF5.js.map +1 -0
- package/dist/esm/{editor-JX42GFAZ.js → editor-Z24WLBPO.js} +5 -5
- package/dist/esm/editor-Z24WLBPO.js.map +1 -0
- package/dist/esm/index.js +34 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +532 -446
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/code-editor/index.tsx +2 -2
- package/src/components/condition-row/constants.ts +8 -0
- package/src/components/display-inputs-values/index.tsx +1 -1
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +1 -1
- package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/json-editor-with-variables/index.tsx +2 -2
- package/src/components/json-schema-editor/hooks.tsx +1 -1
- package/src/components/prompt-editor/index.tsx +2 -2
- package/src/components/prompt-editor-with-inputs/index.tsx +2 -2
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/prompt-editor-with-variables/index.tsx +2 -2
- package/src/components/variable-selector/context.tsx +28 -0
- package/src/components/variable-selector/index.tsx +10 -1
- package/src/components/variable-selector/use-variable-tree.tsx +3 -3
- package/src/effects/validate-when-variable-sync/index.ts +1 -1
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
- package/src/hooks/use-object-list/index.tsx +1 -1
- package/src/plugins/json-schema-preset/type-definition/date-time.tsx +25 -0
- package/src/plugins/json-schema-preset/type-definition/index.tsx +2 -0
- package/src/shared/flow-value/utils.ts +1 -1
- package/src/shared/format-legacy-refs/index.ts +1 -1
- package/src/shared/index.ts +1 -0
- package/src/shared/lazy-suspense/index.tsx +28 -0
- package/src/validate/validate-flow-value/index.tsx +1 -1
- package/dist/esm/chunk-6OZSB6PD.js.map +0 -1
- package/dist/esm/chunk-G4HQ7OSI.js.map +0 -1
- package/dist/esm/chunk-QIJ4QVB2.js.map +0 -1
- package/dist/esm/editor-H2R7JJLO.js.map +0 -1
- package/dist/esm/editor-JX42GFAZ.js.map +0 -1
- package/dist/esm/editor-YMNCDGUR.js.map +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySuspense
|
|
3
|
+
} from "./chunk-DEZUEMUM.js";
|
|
4
|
+
|
|
1
5
|
// src/components/prompt-editor/index.tsx
|
|
2
|
-
|
|
3
|
-
var PromptEditor = lazy(
|
|
6
|
+
var PromptEditor = lazySuspense(
|
|
4
7
|
() => import("./editor-6UMULJYB.js").then((module) => ({ default: module.PromptEditor }))
|
|
5
8
|
);
|
|
6
9
|
|
|
7
10
|
export {
|
|
8
11
|
PromptEditor
|
|
9
12
|
};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-727SU246.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/prompt-editor/index.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { lazySuspense } from '@/shared';\n\nexport const PromptEditor = lazySuspense(() =>\n import('./editor').then((module) => ({ default: module.PromptEditor }))\n);\n\nexport type { PromptEditorPropsType } from './editor';\n"],"mappings":";;;;;AAOO,IAAM,eAAe;AAAA,EAAa,MACvC,OAAO,sBAAU,EAAE,KAAK,CAAC,YAAY,EAAE,SAAS,OAAO,aAAa,EAAE;AACxE;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/shared/format-legacy-refs/index.ts
|
|
2
|
-
import { isObject } from "lodash";
|
|
2
|
+
import { isObject } from "lodash-es";
|
|
3
3
|
function formatLegacyRefOnSubmit(value) {
|
|
4
4
|
if (isObject(value)) {
|
|
5
5
|
if (isLegacyFlowRefValueSchema(value)) {
|
|
@@ -87,7 +87,7 @@ function createInjectMaterial(Component, params) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// src/shared/flow-value/utils.ts
|
|
90
|
-
import { isArray, isObject as isObject2, isPlainObject, uniq } from "lodash";
|
|
90
|
+
import { isArray, isObject as isObject2, isPlainObject, uniq } from "lodash-es";
|
|
91
91
|
import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
|
|
92
92
|
|
|
93
93
|
// src/shared/flow-value/schema.ts
|
|
@@ -256,6 +256,17 @@ function unstableSetCreateRoot(createRoot) {
|
|
|
256
256
|
unstableCreateRoot = createRoot;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
// src/shared/lazy-suspense/index.tsx
|
|
260
|
+
import React2, { lazy, Suspense } from "react";
|
|
261
|
+
import { Skeleton } from "@douyinfe/semi-ui";
|
|
262
|
+
function withSuspense(Component, fallback) {
|
|
263
|
+
const WithSuspenseComponent = (props) => /* @__PURE__ */ React2.createElement(Suspense, { fallback: fallback || /* @__PURE__ */ React2.createElement(Skeleton.Paragraph, { style: { width: "100%" }, rows: 1 }) }, /* @__PURE__ */ React2.createElement(Component, { ...props }));
|
|
264
|
+
return WithSuspenseComponent;
|
|
265
|
+
}
|
|
266
|
+
function lazySuspense(params, fallback) {
|
|
267
|
+
return withSuspense(lazy(params), fallback);
|
|
268
|
+
}
|
|
269
|
+
|
|
259
270
|
export {
|
|
260
271
|
formatLegacyRefOnSubmit,
|
|
261
272
|
formatLegacyRefOnInit,
|
|
@@ -266,6 +277,8 @@ export {
|
|
|
266
277
|
createInjectMaterial,
|
|
267
278
|
FlowValueUtils,
|
|
268
279
|
polyfillCreateRoot,
|
|
269
|
-
unstableSetCreateRoot
|
|
280
|
+
unstableSetCreateRoot,
|
|
281
|
+
withSuspense,
|
|
282
|
+
lazySuspense
|
|
270
283
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
284
|
+
//# sourceMappingURL=chunk-DEZUEMUM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared/format-legacy-refs/index.ts","../../src/shared/inject-material/index.tsx","../../src/shared/flow-value/utils.ts","../../src/shared/flow-value/schema.ts","../../src/shared/polyfill-create-root/index.tsx","../../src/shared/lazy-suspense/index.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { isObject } from 'lodash-es';\n\ninterface LegacyFlowRefValueSchema {\n type: 'ref';\n content: string;\n}\n\ninterface NewFlowRefValueSchema {\n type: 'ref';\n content: string[];\n}\n\n/**\n * In flowgram 0.2.0, for introducing Loop variable functionality,\n * the FlowRefValueSchema type definition is updated:\n *\n * interface LegacyFlowRefValueSchema {\n * type: 'ref';\n * content: string;\n * }\n *\n * interface NewFlowRefValueSchema {\n * type: 'ref';\n * content: string[];\n * }\n *\n *\n * For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData\n *\n * How to use:\n *\n * 1. Call formatLegacyRefOnSubmit on the formData before submitting\n * 2. Call formatLegacyRefOnInit on the formData after submitting\n *\n * Example:\n * import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';\n * formMeta: {\n * formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),\n * formatOnInit: (data) => formatLegacyRefOnInit(data),\n * }\n */\nexport function formatLegacyRefOnSubmit(value: any): any {\n if (isObject(value)) {\n if (isLegacyFlowRefValueSchema(value)) {\n return formatLegacyRefToNewRef(value);\n }\n\n return Object.fromEntries(\n Object.entries(value).map(([key, value]: [string, any]) => [\n key,\n formatLegacyRefOnSubmit(value),\n ])\n );\n }\n\n if (Array.isArray(value)) {\n return value.map(formatLegacyRefOnSubmit);\n }\n\n return value;\n}\n\n/**\n * In flowgram 0.2.0, for introducing Loop variable functionality,\n * the FlowRefValueSchema type definition is updated:\n *\n * interface LegacyFlowRefValueSchema {\n * type: 'ref';\n * content: string;\n * }\n *\n * interface NewFlowRefValueSchema {\n * type: 'ref';\n * content: string[];\n * }\n *\n *\n * For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData\n *\n * How to use:\n *\n * 1. Call formatLegacyRefOnSubmit on the formData before submitting\n * 2. Call formatLegacyRefOnInit on the formData after submitting\n *\n * Example:\n * import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';\n *\n * formMeta: {\n * formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),\n * formatOnInit: (data) => formatLegacyRefOnInit(data),\n * }\n */\nexport function formatLegacyRefOnInit(value: any): any {\n if (isObject(value)) {\n if (isNewFlowRefValueSchema(value)) {\n return formatNewRefToLegacyRef(value);\n }\n\n return Object.fromEntries(\n Object.entries(value).map(([key, value]: [string, any]) => [\n key,\n formatLegacyRefOnInit(value),\n ])\n );\n }\n\n if (Array.isArray(value)) {\n return value.map(formatLegacyRefOnInit);\n }\n\n return value;\n}\n\nexport function isLegacyFlowRefValueSchema(value: any): value is LegacyFlowRefValueSchema {\n return (\n isObject(value) &&\n Object.keys(value).length === 2 &&\n (value as any).type === 'ref' &&\n typeof (value as any).content === 'string'\n );\n}\n\nexport function isNewFlowRefValueSchema(value: any): value is NewFlowRefValueSchema {\n return (\n isObject(value) &&\n Object.keys(value).length === 2 &&\n (value as any).type === 'ref' &&\n Array.isArray((value as any).content)\n );\n}\n\nexport function formatLegacyRefToNewRef(value: LegacyFlowRefValueSchema) {\n const keyPath = value.content.split('.');\n\n if (keyPath[1] === 'outputs') {\n return {\n type: 'ref',\n content: [`${keyPath[0]}.${keyPath[1]}`, ...(keyPath.length > 2 ? keyPath.slice(2) : [])],\n };\n }\n\n return {\n type: 'ref',\n content: keyPath,\n };\n}\n\nexport function formatNewRefToLegacyRef(value: NewFlowRefValueSchema) {\n return {\n type: 'ref',\n content: value.content.join('.'),\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport {\n FlowRendererComponentType,\n FlowRendererRegistry,\n usePlaygroundContainer,\n} from '@flowgram.ai/editor';\n\n/**\n * Creates a material component wrapper with dependency injection support\n *\n * This Higher-Order Component (HOC) implements a dynamic component replacement mechanism\n * for material components. It automatically checks if a custom renderer is registered\n * in the editor context, using the injected component if available, otherwise\n * falling back to the default component.\n *\n * @example\n * ```tsx\n * // 1.Create an injectable material component\n * const InjectVariableSelector = createInjectMaterial(VariableSelector)\n *\n * // 2. Register custom components in editor\n * // Configure in use-editor-props.tsx:\n * const editorProps = {\n * materials: {\n * components: {\n * [VariableSelector.renderKey]: YourCustomVariableSelector\n * }\n * }\n * }\n * ```\n *\n * @description\n * Data flow explanation:\n * - Register components to FlowRendererRegistry in use-editor-props\n * - InjectMaterial reads renderers from FlowRendererRegistry\n * - If registered renderer exists and type is REACT, use injected component\n * - If not exists or type mismatch, fallback to default component\n *\n * @param Component - Default React component\n * @param params - Optional parameters\n * @param params.renderKey - Custom render key name, highest priority\n * @returns Wrapper component with dependency injection support\n */\nexport function createInjectMaterial<Props>(\n Component: React.FC<Props> & { renderKey?: string },\n params?: {\n renderKey?: string;\n }\n): React.FC<Props> {\n const InjectComponent: React.FC<Props> = (props) => {\n const container = usePlaygroundContainer();\n\n // Check if renderer registry is bound in container\n if (!container?.isBound(FlowRendererRegistry)) {\n // If no registry, use default component directly\n return React.createElement(Component as (props?: any) => any, { ...props });\n }\n\n // Get renderer registry instance\n const rendererRegistry = container.get(FlowRendererRegistry);\n\n // Determine render key: prioritize param specified, then component renderKey, finally component name\n const renderKey = params?.renderKey || Component.renderKey || Component.name || '';\n\n // Get corresponding renderer from registry\n const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);\n\n // Check if renderer exists and type is React component\n if (renderer?.type !== FlowRendererComponentType.REACT) {\n // If no suitable renderer found, fallback to default component\n return React.createElement(Component as (props?: any) => any, { ...props });\n }\n\n // Render using injected React component\n return React.createElement(renderer.renderer, {\n ...props,\n });\n };\n\n return InjectComponent;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { isArray, isObject, isPlainObject, uniq } from 'lodash-es';\nimport { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';\nimport { Scope } from '@flowgram.ai/editor';\n\nimport {\n IFlowConstantValue,\n IFlowRefValue,\n IFlowExpressionValue,\n IFlowTemplateValue,\n IFlowValue,\n IFlowConstantRefValue,\n FlowValueType,\n} from '@/typings';\n\nimport { constantSchema, refSchema, expressionSchema, templateSchema } from './schema';\n\nexport namespace FlowValueUtils {\n /**\n * Check if the value is a constant type\n */\n export function isConstant(value: any): value is IFlowConstantValue {\n return constantSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is a reference type\n */\n export function isRef(value: any): value is IFlowRefValue {\n return refSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is an expression type\n */\n export function isExpression(value: any): value is IFlowExpressionValue {\n return expressionSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is a template type\n */\n export function isTemplate(value: any): value is IFlowTemplateValue {\n return templateSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is either a constant or reference type\n */\n export function isConstantOrRef(value: any): value is IFlowConstantRefValue {\n return isConstant(value) || isRef(value);\n }\n\n /**\n * Check if the value is a valid flow value type\n */\n export function isFlowValue(value: any): value is IFlowValue {\n return isConstant(value) || isRef(value) || isExpression(value) || isTemplate(value);\n }\n\n /**\n * Traverse all flow values in the given value\n * @param value The value to traverse\n * @param options The options to traverse\n * @returns A generator of flow values\n */\n export function* traverse(\n value: any,\n options: {\n includeTypes?: FlowValueType[];\n path?: string;\n }\n ): Generator<{ value: IFlowValue; path: string }> {\n const { includeTypes = ['ref', 'template'], path = '' } = options;\n\n if (isPlainObject(value)) {\n if (isRef(value) && includeTypes.includes('ref')) {\n yield { value, path };\n return;\n }\n\n if (isTemplate(value) && includeTypes.includes('template')) {\n yield { value, path };\n return;\n }\n\n if (isExpression(value) && includeTypes.includes('expression')) {\n yield { value, path };\n return;\n }\n\n if (isConstant(value) && includeTypes.includes('constant')) {\n yield { value, path };\n return;\n }\n\n for (const [_key, _value] of Object.entries(value)) {\n yield* traverse(_value, { ...options, path: `${path}.${_key}` });\n }\n return;\n }\n\n if (isArray(value)) {\n for (const [_idx, _value] of value.entries()) {\n yield* traverse(_value, { ...options, path: `${path}[${_idx}]` });\n }\n return;\n }\n\n return;\n }\n\n /**\n * Get all key paths in the template value\n * @param value The template value\n * @returns A list of key paths\n */\n export function getTemplateKeyPaths(value: IFlowTemplateValue) {\n // find all keyPath wrapped in {{}}\n const keyPathReg = /\\{\\{([^\\}\\{]+)\\}\\}/g;\n return uniq(value.content?.match(keyPathReg) || []).map((_keyPath) =>\n _keyPath.slice(2, -2).split('.')\n );\n }\n\n /**\n * Infer the schema of the constant value\n * @param value\n * @returns\n */\n export function inferConstantJsonSchema(value: IFlowConstantValue): IJsonSchema | undefined {\n if (value?.schema) {\n return value.schema;\n }\n\n if (typeof value.content === 'string') {\n return {\n type: 'string',\n };\n }\n\n if (typeof value.content === 'number') {\n return {\n type: 'number',\n };\n }\n\n if (typeof value.content === 'boolean') {\n return {\n type: 'boolean',\n };\n }\n\n if (isObject(value.content)) {\n return {\n type: 'object',\n };\n }\n return undefined;\n }\n\n /**\n * Infer the schema of the flow value\n * @param values The flow value or object contains flow value\n * @param scope\n * @returns\n */\n export function inferJsonSchema(values: any, scope: Scope): IJsonSchema | undefined {\n if (isPlainObject(values)) {\n if (isConstant(values)) {\n return inferConstantJsonSchema(values);\n }\n\n if (isRef(values)) {\n const variable = scope.available.getByKeyPath(values?.content);\n const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : undefined;\n\n return schema;\n }\n\n if (isTemplate(values)) {\n return { type: 'string' };\n }\n\n return {\n type: 'object',\n properties: Object.keys(values).reduce((acc, key) => {\n const schema = inferJsonSchema((values as any)[key], scope);\n if (schema) {\n acc[key] = schema;\n }\n return acc;\n }, {} as Record<string, IJsonSchema>),\n };\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport z from 'zod';\n\n// Shared extra schema for flow value types\nexport const extraSchema = z\n .object({\n index: z.number().optional(),\n })\n .optional();\n\nexport const constantSchema = z.object({\n type: z.literal('constant'),\n content: z.any().optional(),\n schema: z.any().optional(),\n extra: extraSchema,\n});\n\nexport const refSchema = z.object({\n type: z.literal('ref'),\n content: z.array(z.string()).optional(),\n extra: extraSchema,\n});\n\nexport const expressionSchema = z.object({\n type: z.literal('expression'),\n content: z.string().optional(),\n extra: extraSchema,\n});\n\nexport const templateSchema = z.object({\n type: z.literal('template'),\n content: z.string().optional(),\n extra: extraSchema,\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport * as ReactDOM from 'react-dom';\n\nexport interface IPolyfillRoot {\n render(children: React.ReactNode): void;\n unmount(): void;\n}\n\n/**\n * React 18 polyfill\n * @param dom\n * @returns\n */\nlet unstableCreateRoot = (dom: HTMLElement): IPolyfillRoot => ({\n render(children: JSX.Element) {\n ReactDOM.render(children, dom);\n },\n unmount() {\n ReactDOM.unmountComponentAtNode(dom);\n },\n});\n\nexport function polyfillCreateRoot(dom: HTMLElement): IPolyfillRoot {\n return unstableCreateRoot(dom);\n}\n\nexport function unstableSetCreateRoot(createRoot: (dom: HTMLElement) => IPolyfillRoot) {\n unstableCreateRoot = createRoot;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { ComponentType, lazy, Suspense } from 'react';\n\nimport { Skeleton } from '@douyinfe/semi-ui';\n\nexport function withSuspense<T extends ComponentType<any>>(\n Component: T,\n fallback?: React.ReactNode\n): T {\n const WithSuspenseComponent: T = ((props: any) => (\n <Suspense fallback={fallback || <Skeleton.Paragraph style={{ width: '100%' }} rows={1} />}>\n <Component {...props} />\n </Suspense>\n )) as any;\n\n return WithSuspenseComponent;\n}\n\nexport function lazySuspense<T extends ComponentType<any>>(\n params: Parameters<typeof lazy<T>>[0],\n fallback?: React.ReactNode\n) {\n return withSuspense(lazy(params), fallback);\n}\n"],"mappings":";AAKA,SAAS,gBAAgB;AAyClB,SAAS,wBAAwB,OAAiB;AACvD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,2BAA2B,KAAK,GAAG;AACrC,aAAO,wBAAwB,KAAK;AAAA,IACtC;AAEA,WAAO,OAAO;AAAA,MACZ,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAKA,MAAK,MAAqB;AAAA,QACzD;AAAA,QACA,wBAAwBA,MAAK;AAAA,MAC/B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,uBAAuB;AAAA,EAC1C;AAEA,SAAO;AACT;AAgCO,SAAS,sBAAsB,OAAiB;AACrD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,wBAAwB,KAAK,GAAG;AAClC,aAAO,wBAAwB,KAAK;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C;","names":["value","isObject","FlowValueUtils","isObject","React"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createInjectMaterial
|
|
3
|
-
|
|
2
|
+
createInjectMaterial,
|
|
3
|
+
lazySuspense
|
|
4
|
+
} from "./chunk-DEZUEMUM.js";
|
|
4
5
|
|
|
5
6
|
// src/components/code-editor/index.tsx
|
|
6
|
-
|
|
7
|
-
var CodeEditor = lazy(
|
|
7
|
+
var CodeEditor = lazySuspense(
|
|
8
8
|
() => import("./editor-E2BQTPCD.js").then((module) => ({ default: module.CodeEditor }))
|
|
9
9
|
);
|
|
10
10
|
|
|
@@ -119,15 +119,33 @@ var integerRegistry = {
|
|
|
119
119
|
)
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
// src/plugins/json-schema-preset/type-definition/
|
|
122
|
+
// src/plugins/json-schema-preset/type-definition/date-time.tsx
|
|
123
123
|
import React6 from "react";
|
|
124
|
+
import { DatePicker } from "@douyinfe/semi-ui";
|
|
125
|
+
var dateTimeRegistry = {
|
|
126
|
+
type: "date-time",
|
|
127
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
128
|
+
DatePicker,
|
|
129
|
+
{
|
|
130
|
+
size: "small",
|
|
131
|
+
type: "dateTime",
|
|
132
|
+
density: "compact",
|
|
133
|
+
style: { width: "100%", ...props.style || {} },
|
|
134
|
+
disabled: props.readonly,
|
|
135
|
+
...props
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
141
|
+
import React7 from "react";
|
|
124
142
|
import { I18n as I18n5 } from "@flowgram.ai/editor";
|
|
125
143
|
import { Select } from "@douyinfe/semi-ui";
|
|
126
144
|
var booleanRegistry = {
|
|
127
145
|
type: "boolean",
|
|
128
146
|
ConstantRenderer: (props) => {
|
|
129
147
|
const { value, onChange, ...rest } = props;
|
|
130
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ React7.createElement(
|
|
131
149
|
Select,
|
|
132
150
|
{
|
|
133
151
|
placeholder: I18n5.t("Please Select Boolean"),
|
|
@@ -146,11 +164,11 @@ var booleanRegistry = {
|
|
|
146
164
|
};
|
|
147
165
|
|
|
148
166
|
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
149
|
-
import
|
|
167
|
+
import React8 from "react";
|
|
150
168
|
import { I18n as I18n6 } from "@flowgram.ai/editor";
|
|
151
169
|
var arrayRegistry = {
|
|
152
170
|
type: "array",
|
|
153
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
171
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React8.createElement(
|
|
154
172
|
CodeEditorMini,
|
|
155
173
|
{
|
|
156
174
|
value: props.value,
|
|
@@ -169,7 +187,8 @@ var jsonSchemaTypePreset = [
|
|
|
169
187
|
numberRegistry,
|
|
170
188
|
integerRegistry,
|
|
171
189
|
booleanRegistry,
|
|
172
|
-
arrayRegistry
|
|
190
|
+
arrayRegistry,
|
|
191
|
+
dateTimeRegistry
|
|
173
192
|
];
|
|
174
193
|
jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
|
|
175
194
|
|
|
@@ -185,7 +204,7 @@ var createTypePresetPlugin = definePluginCreator({
|
|
|
185
204
|
});
|
|
186
205
|
|
|
187
206
|
// src/plugins/json-schema-preset/index.tsx
|
|
188
|
-
import
|
|
207
|
+
import React9 from "react";
|
|
189
208
|
import {
|
|
190
209
|
JsonSchemaUtils,
|
|
191
210
|
useTypeManager as useOriginTypeManager,
|
|
@@ -195,7 +214,7 @@ var useTypeManager = () => useOriginTypeManager();
|
|
|
195
214
|
var JsonSchemaTypePresetProvider = ({
|
|
196
215
|
types = [],
|
|
197
216
|
children
|
|
198
|
-
}) => /* @__PURE__ */
|
|
217
|
+
}) => /* @__PURE__ */ React9.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
199
218
|
|
|
200
219
|
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
201
220
|
import {
|
|
@@ -222,23 +241,23 @@ var createDisableDeclarationPlugin = definePluginCreator2({
|
|
|
222
241
|
});
|
|
223
242
|
|
|
224
243
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
225
|
-
import
|
|
244
|
+
import React10, { useCallback } from "react";
|
|
226
245
|
import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
|
|
227
246
|
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
228
247
|
import { Icon } from "@douyinfe/semi-ui";
|
|
229
248
|
function useVariableTree(params) {
|
|
230
|
-
const { includeSchema, excludeSchema,
|
|
249
|
+
const { includeSchema, excludeSchema, skipVariable } = params;
|
|
231
250
|
const typeManager = useTypeManager();
|
|
232
251
|
const variables = useAvailableVariables();
|
|
233
252
|
const getVariableTypeIcon = useCallback((variable) => {
|
|
234
253
|
if (variable.meta?.icon) {
|
|
235
254
|
if (typeof variable.meta.icon === "string") {
|
|
236
|
-
return /* @__PURE__ */
|
|
255
|
+
return /* @__PURE__ */ React10.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
237
256
|
}
|
|
238
257
|
return variable.meta.icon;
|
|
239
258
|
}
|
|
240
259
|
const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
|
|
241
|
-
return /* @__PURE__ */
|
|
260
|
+
return /* @__PURE__ */ React10.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
242
261
|
}, []);
|
|
243
262
|
const renderVariable = (variable, parentFields = []) => {
|
|
244
263
|
let type = variable?.type;
|
|
@@ -253,7 +272,7 @@ function useVariableTree(params) {
|
|
|
253
272
|
const key = keyPath.join(".");
|
|
254
273
|
const isSchemaInclude = includeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, includeSchema) : true;
|
|
255
274
|
const isSchemaExclude = excludeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, excludeSchema) : false;
|
|
256
|
-
const isCustomSkip =
|
|
275
|
+
const isCustomSkip = skipVariable ? skipVariable(variable) : false;
|
|
257
276
|
const isMetaDisabled = variable.meta?.disabled;
|
|
258
277
|
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
|
|
259
278
|
if (!isSchemaMatch && !children?.length) {
|
|
@@ -274,8 +293,20 @@ function useVariableTree(params) {
|
|
|
274
293
|
return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
275
294
|
}
|
|
276
295
|
|
|
296
|
+
// src/components/variable-selector/context.tsx
|
|
297
|
+
import React11, { createContext, useContext, useMemo } from "react";
|
|
298
|
+
var VariableSelectorContext = createContext({});
|
|
299
|
+
var useVariableSelectorContext = () => useContext(VariableSelectorContext);
|
|
300
|
+
var VariableSelectorProvider = ({
|
|
301
|
+
children,
|
|
302
|
+
skipVariable
|
|
303
|
+
}) => {
|
|
304
|
+
const context = useMemo(() => ({ skipVariable }), [skipVariable]);
|
|
305
|
+
return /* @__PURE__ */ React11.createElement(VariableSelectorContext.Provider, { value: context }, children);
|
|
306
|
+
};
|
|
307
|
+
|
|
277
308
|
// src/components/variable-selector/index.tsx
|
|
278
|
-
import
|
|
309
|
+
import React12, { useMemo as useMemo2 } from "react";
|
|
279
310
|
import { I18n as I18n7 } from "@flowgram.ai/editor";
|
|
280
311
|
import { Popover } from "@douyinfe/semi-ui";
|
|
281
312
|
import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
@@ -351,8 +382,13 @@ var VariableSelector = ({
|
|
|
351
382
|
hasError,
|
|
352
383
|
triggerRender
|
|
353
384
|
}) => {
|
|
354
|
-
const
|
|
355
|
-
const
|
|
385
|
+
const { skipVariable } = useVariableSelectorContext();
|
|
386
|
+
const treeData = useVariableTree({
|
|
387
|
+
includeSchema,
|
|
388
|
+
excludeSchema,
|
|
389
|
+
skipVariable
|
|
390
|
+
});
|
|
391
|
+
const treeValue = useMemo2(() => {
|
|
356
392
|
if (typeof value === "string") {
|
|
357
393
|
console.warn(
|
|
358
394
|
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
@@ -364,11 +400,11 @@ var VariableSelector = ({
|
|
|
364
400
|
}, [value]);
|
|
365
401
|
const renderIcon = (icon) => {
|
|
366
402
|
if (typeof icon === "string") {
|
|
367
|
-
return /* @__PURE__ */
|
|
403
|
+
return /* @__PURE__ */ React12.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
368
404
|
}
|
|
369
405
|
return icon;
|
|
370
406
|
};
|
|
371
|
-
return /* @__PURE__ */
|
|
407
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
|
|
372
408
|
UITreeSelect,
|
|
373
409
|
{
|
|
374
410
|
dropdownMatchSelectWidth: false,
|
|
@@ -385,10 +421,10 @@ var VariableSelector = ({
|
|
|
385
421
|
},
|
|
386
422
|
renderSelectedItem: (_option) => {
|
|
387
423
|
if (!_option?.keyPath) {
|
|
388
|
-
return /* @__PURE__ */
|
|
424
|
+
return /* @__PURE__ */ React12.createElement(
|
|
389
425
|
UITag,
|
|
390
426
|
{
|
|
391
|
-
prefixIcon: /* @__PURE__ */
|
|
427
|
+
prefixIcon: /* @__PURE__ */ React12.createElement(IconIssueStroked, null),
|
|
392
428
|
color: "amber",
|
|
393
429
|
closable: !readonly,
|
|
394
430
|
onClose: () => onChange(void 0)
|
|
@@ -397,13 +433,13 @@ var VariableSelector = ({
|
|
|
397
433
|
);
|
|
398
434
|
}
|
|
399
435
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
400
|
-
const rootTitle = /* @__PURE__ */
|
|
401
|
-
return /* @__PURE__ */
|
|
436
|
+
const rootTitle = /* @__PURE__ */ React12.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
437
|
+
return /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(
|
|
402
438
|
Popover,
|
|
403
439
|
{
|
|
404
|
-
content: /* @__PURE__ */
|
|
440
|
+
content: /* @__PURE__ */ React12.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React12.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
405
441
|
},
|
|
406
|
-
/* @__PURE__ */
|
|
442
|
+
/* @__PURE__ */ React12.createElement(
|
|
407
443
|
UITag,
|
|
408
444
|
{
|
|
409
445
|
prefixIcon: rootIcon,
|
|
@@ -411,12 +447,12 @@ var VariableSelector = ({
|
|
|
411
447
|
onClose: () => onChange(void 0)
|
|
412
448
|
},
|
|
413
449
|
rootTitle,
|
|
414
|
-
!_option.isRoot && /* @__PURE__ */
|
|
450
|
+
!_option.isRoot && /* @__PURE__ */ React12.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
415
451
|
)
|
|
416
452
|
));
|
|
417
453
|
},
|
|
418
454
|
showClear: false,
|
|
419
|
-
arrowIcon: /* @__PURE__ */
|
|
455
|
+
arrowIcon: /* @__PURE__ */ React12.createElement(IconChevronDownStroked, { size: "small" }),
|
|
420
456
|
triggerRender,
|
|
421
457
|
placeholder: config?.placeholder ?? I18n7.t("Select Variable")
|
|
422
458
|
}
|
|
@@ -434,7 +470,8 @@ export {
|
|
|
434
470
|
JsonSchemaTypePresetProvider,
|
|
435
471
|
createDisableDeclarationPlugin,
|
|
436
472
|
useVariableTree,
|
|
473
|
+
VariableSelectorProvider,
|
|
437
474
|
VariableSelector,
|
|
438
475
|
InjectVariableSelector
|
|
439
476
|
};
|
|
440
|
-
//# sourceMappingURL=chunk-
|
|
477
|
+
//# sourceMappingURL=chunk-IHOHRV5V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/code-editor/index.tsx","../../src/components/code-editor-mini/index.tsx","../../src/plugins/json-schema-preset/create-type-preset-plugin.tsx","../../src/plugins/json-schema-preset/type-definition/index.tsx","../../src/plugins/json-schema-preset/type-definition/string.tsx","../../src/plugins/json-schema-preset/type-definition/object.tsx","../../src/plugins/json-schema-preset/type-definition/number.tsx","../../src/plugins/json-schema-preset/type-definition/integer.tsx","../../src/plugins/json-schema-preset/type-definition/date-time.tsx","../../src/plugins/json-schema-preset/type-definition/boolean.tsx","../../src/plugins/json-schema-preset/type-definition/array.tsx","../../src/plugins/json-schema-preset/index.tsx","../../src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts","../../src/components/variable-selector/use-variable-tree.tsx","../../src/components/variable-selector/context.tsx","../../src/components/variable-selector/index.tsx","../../src/components/variable-selector/styles.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { lazySuspense } from '@/shared';\n\nexport const CodeEditor = lazySuspense(() =>\n import('./editor').then((module) => ({ default: module.CodeEditor }))\n);\n\nexport type { CodeEditorPropsType } from './editor';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport styled from 'styled-components';\n\nimport { CodeEditor, type CodeEditorPropsType } from '@/components/code-editor';\n\nconst UIMini = styled.div`\n .ͼ1 .cm-content {\n }\n`;\n\nexport function CodeEditorMini(props: CodeEditorPropsType) {\n return (\n <UIMini>\n <CodeEditor\n {...props}\n options={{\n lineNumbersGutter: false,\n foldGutter: false,\n minHeight: 24,\n ...(props.options || {}),\n }}\n />\n </UIMini>\n );\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n BaseTypeManager,\n jsonSchemaContainerModule,\n JsonSchemaTypeManager,\n} from '@flowgram.ai/json-schema';\nimport { definePluginCreator } from '@flowgram.ai/editor';\n\nimport { jsonSchemaTypePreset } from './type-definition';\nimport { JsonSchemaTypeRegistry } from './manager';\n\nexport const createTypePresetPlugin = definePluginCreator<{\n types?: Partial<JsonSchemaTypeRegistry> & Pick<JsonSchemaTypeRegistry, 'type'>[];\n unregisterTypes?: string[];\n}>({\n onInit(ctx, opts) {\n const typeManager = ctx.get(BaseTypeManager) as JsonSchemaTypeManager;\n jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));\n\n opts.types?.forEach((_type) => typeManager.register(_type));\n opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));\n },\n containerModules: [jsonSchemaContainerModule],\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { jsonSchemaTypeManager } from '@flowgram.ai/json-schema';\n\nimport { stringRegistry } from './string';\nimport { objectRegistry } from './object';\nimport { numberRegistry } from './number';\nimport { integerRegistry } from './integer';\nimport { dateTimeRegistry } from './date-time';\nimport { booleanRegistry } from './boolean';\nimport { arrayRegistry } from './array';\n\nexport const jsonSchemaTypePreset = [\n stringRegistry,\n objectRegistry,\n numberRegistry,\n integerRegistry,\n booleanRegistry,\n arrayRegistry,\n dateTimeRegistry,\n];\n\njsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\nimport React from 'react';\n\nimport { I18n } from '@flowgram.ai/editor';\nimport { Input, TextArea } from '@douyinfe/semi-ui';\n\nimport { type JsonSchemaTypeRegistry } from '../manager';\n\nexport const stringRegistry: Partial<JsonSchemaTypeRegistry> = {\n type: 'string',\n ConstantRenderer: (props) =>\n props?.enableMultiLineStr ? (\n <TextArea\n autosize\n rows={1}\n placeholder={I18n.t('Please Input String')}\n disabled={props.readonly}\n {...props}\n />\n ) : (\n <Input\n size=\"small\"\n placeholder={I18n.t('Please Input String')}\n disabled={props.readonly}\n {...props}\n />\n ),\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\nimport React from 'react';\n\nimport { I18n } from '@flowgram.ai/editor';\n\nimport { CodeEditorMini } from '@/components/code-editor-mini';\n\nimport { type JsonSchemaTypeRegistry } from '../manager';\n\nexport const objectRegistry: Partial<JsonSchemaTypeRegistry> = {\n type: 'object',\n ConstantRenderer: (props) => (\n <CodeEditorMini\n value={props.value}\n onChange={(v) => props.onChange?.(v)}\n languageId=\"json\"\n placeholder={I18n.t('Please Input Object')}\n readonly={props.readonly}\n />\n ),\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\nimport React from 'react';\n\nimport { I18n } from '@flowgram.ai/editor';\nimport { InputNumber } from '@douyinfe/semi-ui';\n\nimport { type JsonSchemaTypeRegistry } from '../manager';\n\nexport const numberRegistry: Partial<JsonSchemaTypeRegistry> = {\n type: 'number',\n ConstantRenderer: (props) => (\n <InputNumber\n placeholder={I18n.t('Please Input Number')}\n size=\"small\"\n disabled={props.readonly}\n hideButtons\n {...props}\n />\n ),\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\nimport React from 'react';\n\nimport { I18n } from '@flowgram.ai/editor';\nimport { InputNumber } from '@douyinfe/semi-ui';\n\nimport { type JsonSchemaTypeRegistry } from '../manager';\n\nexport const integerRegistry: Partial<JsonSchemaTypeRegistry> = {\n type: 'integer',\n ConstantRenderer: (props) => (\n <InputNumber\n placeholder={I18n.t('Please Input Integer')}\n size=\"small\"\n disabled={props.readonly}\n precision={0}\n {...props}\n />\n ),\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\nimport React from 'react';\n\nimport { DatePicker } from '@douyinfe/semi-ui';\n\nimport { type JsonSchemaTypeRegistry } from '../manager';\n\nexport const dateTimeRegistry: Partial<JsonSchemaTypeRegistry> = {\n type: 'date-time',\n ConstantRenderer: (props) => (\n <DatePicker\n size=\"small\"\n type=\"dateTime\"\n density=\"compact\"\n style={{ width: '100%', ...(props.style || {}) }}\n disabled={props.readonly}\n {...props}\n />\n ),\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\nimport React from 'react';\n\nimport { I18n } from '@flowgram.ai/editor';\nimport { Select } from '@douyinfe/semi-ui';\n\nimport { type JsonSchemaTypeRegistry } from '../manager';\n\nexport const booleanRegistry: Partial<JsonSchemaTypeRegistry> = {\n type: 'boolean',\n ConstantRenderer: (props) => {\n const { value, onChange, ...rest } = props;\n return (\n <Select\n placeholder={I18n.t('Please Select Boolean')}\n size=\"small\"\n disabled={props.readonly}\n optionList={[\n { label: I18n.t('True'), value: 1 },\n { label: I18n.t('False'), value: 0 },\n ]}\n value={value ? 1 : 0}\n onChange={(value) => onChange?.(!!value)}\n {...rest}\n />\n );\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\nimport React from 'react';\n\nimport { I18n } from '@flowgram.ai/editor';\n\nimport { CodeEditorMini } from '@/components/code-editor-mini';\n\nimport { type JsonSchemaTypeRegistry } from '../manager';\n\nexport const arrayRegistry: Partial<JsonSchemaTypeRegistry> = {\n type: 'array',\n ConstantRenderer: (props) => (\n <CodeEditorMini\n value={props.value}\n languageId=\"json\"\n onChange={(v) => props.onChange?.(v)}\n placeholder={I18n.t('Please Input Array')}\n readonly={props.readonly}\n />\n ),\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\nimport React from 'react';\n\nimport {\n type IJsonSchema,\n JsonSchemaUtils,\n useTypeManager as useOriginTypeManager,\n TypePresetProvider as OriginTypePresetProvider,\n JsonSchemaTypeManager,\n type JsonSchemaBasicType,\n} from '@flowgram.ai/json-schema';\n\nimport { jsonSchemaTypePreset } from './type-definition';\nimport { type JsonSchemaTypeRegistry, type ConstantRendererProps } from './manager';\nimport { createTypePresetPlugin } from './create-type-preset-plugin';\n\nconst useTypeManager = () =>\n useOriginTypeManager() as JsonSchemaTypeManager<IJsonSchema, JsonSchemaTypeRegistry>;\n\nconst JsonSchemaTypePresetProvider = ({\n types = [],\n children,\n}: React.PropsWithChildren<{ types: JsonSchemaTypeRegistry[] }>) => (\n <OriginTypePresetProvider types={[...jsonSchemaTypePreset, ...types]}>\n {children}\n </OriginTypePresetProvider>\n);\n\nexport {\n createTypePresetPlugin,\n useTypeManager,\n JsonSchemaTypePresetProvider,\n IJsonSchema,\n JsonSchemaUtils,\n JsonSchemaTypeRegistry,\n ConstantRendererProps,\n JsonSchemaBasicType,\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n ASTMatch,\n definePluginCreator,\n type GlobalEventActionType,\n VariableEngine,\n} from '@flowgram.ai/editor';\n\nexport const createDisableDeclarationPlugin = definePluginCreator<void>({\n onInit(ctx) {\n const variableEngine = ctx.get(VariableEngine);\n\n const handleEvent = (action: GlobalEventActionType) => {\n if (ASTMatch.isVariableDeclaration(action.ast)) {\n if (!action.ast.meta?.disabled) {\n action.ast.updateMeta({\n ...(action.ast.meta || {}),\n disabled: true,\n });\n }\n }\n };\n\n variableEngine.onGlobalEvent('NewAST', handleEvent);\n variableEngine.onGlobalEvent('UpdateAST', handleEvent);\n },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useCallback } from 'react';\n\nimport { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';\nimport { ASTMatch, BaseVariableField, useAvailableVariables } from '@flowgram.ai/editor';\nimport { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';\nimport { Icon } from '@douyinfe/semi-ui';\n\nimport { useTypeManager } from '@/plugins';\n\ntype VariableField = BaseVariableField<{\n icon?: string | JSX.Element;\n title?: string;\n disabled?: boolean;\n}>;\n\nexport function useVariableTree(params: {\n includeSchema?: IJsonSchema | IJsonSchema[];\n excludeSchema?: IJsonSchema | IJsonSchema[];\n skipVariable?: (variable: VariableField) => boolean;\n}): TreeNodeData[] {\n const { includeSchema, excludeSchema, skipVariable } = params;\n\n const typeManager = useTypeManager();\n const variables = useAvailableVariables();\n\n const getVariableTypeIcon = useCallback((variable: VariableField) => {\n if (variable.meta?.icon) {\n if (typeof variable.meta.icon === 'string') {\n return <img style={{ marginRight: 8 }} width={12} height={12} src={variable.meta.icon} />;\n }\n\n return variable.meta.icon;\n }\n\n const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });\n\n return <Icon size=\"small\" svg={typeManager.getDisplayIcon(schema || {})} />;\n }, []);\n\n const renderVariable = (\n variable: VariableField,\n parentFields: VariableField[] = []\n ): TreeNodeData | null => {\n let type = variable?.type;\n\n if (!type) {\n return null;\n }\n\n let children: TreeNodeData[] | undefined;\n\n if (ASTMatch.isObject(type)) {\n children = (type.properties || [])\n .map((_property) => renderVariable(_property as VariableField, [...parentFields, variable]))\n .filter(Boolean) as TreeNodeData[];\n }\n\n const keyPath = [...parentFields.map((_field) => _field.key), variable.key];\n const key = keyPath.join('.');\n\n const isSchemaInclude = includeSchema\n ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema)\n : true;\n const isSchemaExclude = excludeSchema\n ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema)\n : false;\n const isCustomSkip = skipVariable ? skipVariable(variable) : false;\n\n // disabled in meta when created\n const isMetaDisabled = variable.meta?.disabled;\n\n const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;\n\n // If not match, and no children, return null\n if (!isSchemaMatch && !children?.length) {\n return null;\n }\n\n return {\n key: key,\n label: variable.meta?.title || variable.key,\n value: key,\n keyPath,\n icon: getVariableTypeIcon(variable),\n children,\n disabled: !isSchemaMatch,\n rootMeta: parentFields[0]?.meta || variable.meta,\n isRoot: !parentFields?.length,\n };\n };\n\n return [...variables.slice(0).reverse()]\n .map((_variable) => renderVariable(_variable as VariableField))\n .filter(Boolean) as TreeNodeData[];\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { createContext, useContext, useMemo } from 'react';\n\nimport { BaseVariableField } from '@flowgram.ai/editor';\n\nexport const VariableSelectorContext = createContext<{\n skipVariable?: (variable?: BaseVariableField) => boolean;\n}>({});\n\nexport const useVariableSelectorContext = () => useContext(VariableSelectorContext);\n\nexport const VariableSelectorProvider = ({\n children,\n skipVariable,\n}: {\n skipVariable?: (variable?: BaseVariableField) => boolean;\n children: React.ReactNode;\n}) => {\n const context = useMemo(() => ({ skipVariable }), [skipVariable]);\n\n return (\n <VariableSelectorContext.Provider value={context}>{children}</VariableSelectorContext.Provider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useMemo } from 'react';\n\nimport { IJsonSchema } from '@flowgram.ai/json-schema';\nimport { I18n } from '@flowgram.ai/editor';\nimport { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';\nimport { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';\nimport { Popover } from '@douyinfe/semi-ui';\nimport { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';\n\nimport { createInjectMaterial } from '@/shared';\n\nimport { useVariableTree } from './use-variable-tree';\nimport { UIPopoverContent, UIRootTitle, UITag, UITreeSelect, UIVarName } from './styles';\nimport { useVariableSelectorContext } from './context';\n\nexport interface VariableSelectorProps {\n value?: string[];\n config?: {\n placeholder?: string;\n notFoundContent?: string;\n };\n onChange: (value?: string[]) => void;\n includeSchema?: IJsonSchema | IJsonSchema[];\n excludeSchema?: IJsonSchema | IJsonSchema[];\n readonly?: boolean;\n hasError?: boolean;\n style?: React.CSSProperties;\n triggerRender?: (props: TriggerRenderProps) => React.ReactNode;\n}\n\nexport { useVariableTree };\n\nexport const VariableSelector = ({\n value,\n config = {},\n onChange,\n style,\n readonly = false,\n includeSchema,\n excludeSchema,\n hasError,\n triggerRender,\n}: VariableSelectorProps) => {\n const { skipVariable } = useVariableSelectorContext();\n\n const treeData = useVariableTree({\n includeSchema,\n excludeSchema,\n skipVariable,\n });\n\n const treeValue = useMemo(() => {\n if (typeof value === 'string') {\n console.warn(\n 'The Value of VariableSelector is a string, it should be an ARRAY. \\n',\n 'Please check the value of VariableSelector \\n'\n );\n return value;\n }\n return value?.join('.');\n }, [value]);\n\n const renderIcon = (icon: string | JSX.Element) => {\n if (typeof icon === 'string') {\n return <img style={{ marginRight: 8 }} width={12} height={12} src={icon} />;\n }\n\n return icon;\n };\n\n return (\n <>\n <UITreeSelect\n dropdownMatchSelectWidth={false}\n disabled={readonly}\n treeData={treeData}\n size=\"small\"\n value={treeValue}\n clearIcon={null}\n $error={hasError}\n style={style}\n validateStatus={hasError ? 'error' : undefined}\n onChange={(_, _config) => {\n onChange((_config as TreeNodeData).keyPath as string[]);\n }}\n renderSelectedItem={(_option: TreeNodeData) => {\n if (!_option?.keyPath) {\n return (\n <UITag\n prefixIcon={<IconIssueStroked />}\n color=\"amber\"\n closable={!readonly}\n onClose={() => onChange(undefined)}\n >\n {config?.notFoundContent ?? 'Undefined'}\n </UITag>\n );\n }\n\n const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);\n\n const rootTitle = (\n <UIRootTitle>\n {_option.rootMeta?.title\n ? `${_option.rootMeta?.title} ${_option.isRoot ? '' : '-'} `\n : null}\n </UIRootTitle>\n );\n\n return (\n <div>\n <Popover\n content={\n <UIPopoverContent>\n {rootIcon}\n {rootTitle}\n <UIVarName>{_option.keyPath.slice(1).join('.')}</UIVarName>\n </UIPopoverContent>\n }\n >\n <UITag\n prefixIcon={rootIcon}\n closable={!readonly}\n onClose={() => onChange(undefined)}\n >\n {rootTitle}\n {!_option.isRoot && <UIVarName $inSelector>{_option.label}</UIVarName>}\n </UITag>\n </Popover>\n </div>\n );\n }}\n showClear={false}\n arrowIcon={<IconChevronDownStroked size=\"small\" />}\n triggerRender={triggerRender}\n placeholder={config?.placeholder ?? I18n.t('Select Variable')}\n />\n </>\n );\n};\n\nVariableSelector.renderKey = 'variable-selector-render-key';\nexport const InjectVariableSelector = createInjectMaterial(VariableSelector);\n\nexport { VariableSelectorProvider } from './context';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport styled, { css } from 'styled-components';\nimport { Tag, TreeSelect } from '@douyinfe/semi-ui';\n\nexport const UIRootTitle = styled.div`\n margin-right: 4px;\n min-width: 20px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--semi-color-text-2);\n`;\n\nexport const UIVarName = styled.div<{ $inSelector?: boolean }>`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n ${({ $inSelector }) =>\n $inSelector &&\n css`\n min-width: 50%;\n `}\n`;\n\nexport const UITag = styled(Tag)`\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n\n & .semi-tag-content-center {\n justify-content: flex-start;\n }\n\n &.semi-tag {\n margin: 0;\n height: 22px;\n }\n`;\n\nexport const UITreeSelect = styled(TreeSelect)<{ $error?: boolean }>`\n outline: ${({ $error }) => ($error ? '1px solid red' : 'none')};\n\n & .semi-tree-select-selection {\n padding: 0px;\n height: 22px;\n }\n\n & .semi-tree-select-selection-content {\n width: 100%;\n }\n\n & .semi-tree-select-selection-placeholder {\n padding-left: 10px;\n }\n`;\n\nexport const UIPopoverContent = styled.div`\n padding: 10px;\n display: inline-flex;\n align-items: center;\n justify-content: flex-start;\n white-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C;AAAA,cACX,SAAS,MAAM,SAAS,MAAS;AAAA;AAAA,YAEhC,QAAQ,mBAAmB;AAAA,UAC9B;AAAA,QAEJ;AAEA,cAAM,WAAW,WAAW,QAAQ,UAAU,QAAQ,SAAS,IAAI;AAEnE,cAAM,YACJ,gBAAAA,QAAA,cAAC,mBACE,QAAQ,UAAU,QACf,GAAG,QAAQ,UAAU,KAAK,IAAI,QAAQ,SAAS,KAAK,GAAG,MACvD,IACN;AAGF,eACE,gBAAAA,QAAA,cAAC,aACC,gBAAAA,QAAA;AAAA,UAAC;AAAA;AAAA,YACC,SACE,gBAAAA,QAAA,cAAC,wBACE,UACA,WACD,gBAAAA,QAAA,cAAC,iBAAW,QAAQ,QAAQ,MAAM,CAAC,EAAE,KAAK,GAAG,CAAE,CACjD;AAAA;AAAA,UAGF,gBAAAA,QAAA;AAAA,YAAC;AAAA;AAAA,cACC,YAAY;AAAA,cACZ,UAAU,CAAC;AAAA,cACX,SAAS,MAAM,SAAS,MAAS;AAAA;AAAA,YAEhC;AAAA,YACA,CAAC,QAAQ,UAAU,gBAAAA,QAAA,cAAC,aAAU,aAAW,QAAE,QAAQ,KAAM;AAAA,UAC5D;AAAA,QACF,CACF;AAAA,MAEJ;AAAA,MACA,WAAW;AAAA,MACX,WAAW,gBAAAA,QAAA,cAAC,0BAAuB,MAAK,SAAQ;AAAA,MAChD;AAAA,MACA,aAAa,QAAQ,eAAeC,MAAK,EAAE,iBAAiB;AAAA;AAAA,EAC9D,CACF;AAEJ;AAEA,iBAAiB,YAAY;AACtB,IAAM,yBAAyB,qBAAqB,gBAAgB;","names":["React","React","I18n","React","I18n","React","I18n","React","I18n","InputNumber","React","React","I18n","value","React","I18n","React","I18n","React","React","definePluginCreator","React","JsonSchemaUtils","ASTMatch","React","JsonSchemaUtils","ASTMatch","React","React","useMemo","I18n","styled","useMemo","React","I18n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CodeEditor,
|
|
3
3
|
useVariableTree
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IHOHRV5V.js";
|
|
5
5
|
import {
|
|
6
6
|
polyfillCreateRoot
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DEZUEMUM.js";
|
|
8
8
|
|
|
9
9
|
// src/components/json-editor-with-variables/editor.tsx
|
|
10
10
|
import React3 from "react";
|
|
@@ -75,7 +75,7 @@ function VariableTree() {
|
|
|
75
75
|
|
|
76
76
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
77
77
|
import React2, { useLayoutEffect } from "react";
|
|
78
|
-
import { isEqual, last } from "lodash";
|
|
78
|
+
import { isEqual, last } from "lodash-es";
|
|
79
79
|
import {
|
|
80
80
|
Disposable,
|
|
81
81
|
DisposableCollection,
|
|
@@ -279,4 +279,4 @@ function JsonEditorWithVariables(props) {
|
|
|
279
279
|
export {
|
|
280
280
|
JsonEditorWithVariables
|
|
281
281
|
};
|
|
282
|
-
//# sourceMappingURL=editor-
|
|
282
|
+
//# sourceMappingURL=editor-4X7K477H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/json-editor-with-variables/editor.tsx","../../src/components/json-editor-with-variables/extensions/variable-tree.tsx","../../src/components/json-editor-with-variables/extensions/variable-tag.tsx","../../src/components/json-editor-with-variables/styles.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { I18n } from '@flowgram.ai/editor';\nimport { transformerCreator } from '@coze-editor/editor/preset-code';\nimport { Text } from '@coze-editor/editor/language-json';\n\nimport { CodeEditor, type CodeEditorPropsType } from '@/components/code-editor';\n\nimport { VariableTree } from './extensions/variable-tree';\nimport { VariableTagInject } from './extensions/variable-tag';\n\ntype Match = { match: string; range: [number, number] };\nfunction findAllMatches(inputString: string, regex: RegExp): Match[] {\n const globalRegex = new RegExp(\n regex,\n regex.flags.includes('g') ? regex.flags : regex.flags + 'g'\n );\n let match;\n const matches: Match[] = [];\n\n while ((match = globalRegex.exec(inputString)) !== null) {\n if (match.index === globalRegex.lastIndex) {\n globalRegex.lastIndex++;\n }\n matches.push({\n match: match[0],\n range: [match.index, match.index + match[0].length],\n });\n }\n\n return matches;\n}\n\nconst transformer = transformerCreator((text: Text) => {\n const originalSource = text.toString();\n const matches = findAllMatches(originalSource, /\\{\\{([^\\}]*)\\}\\}/g);\n\n if (matches.length > 0) {\n matches.forEach(({ range }) => {\n text.replaceRange(range[0], range[1], 'null');\n });\n }\n\n return text;\n});\n\nexport interface JsonEditorWithVariablesProps extends Omit<CodeEditorPropsType, 'languageId'> {}\n\nexport function JsonEditorWithVariables(props: JsonEditorWithVariablesProps) {\n return (\n <CodeEditor\n languageId=\"json\"\n activeLinePlaceholder={I18n.t(\"Press '@' to Select variable\")}\n {...props}\n options={{\n transformer,\n ...(props.options || {}),\n }}\n >\n <VariableTree />\n <VariableTagInject />\n </CodeEditor>\n );\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useEffect, useState } from 'react';\n\nimport { Popover, Tree } from '@douyinfe/semi-ui';\nimport {\n Mention,\n MentionOpenChangeEvent,\n getCurrentMentionReplaceRange,\n useEditor,\n PositionMirror,\n} from '@coze-editor/editor/react';\nimport { EditorAPI } from '@coze-editor/editor/preset-prompt';\n\nimport { useVariableTree } from '@/components/variable-selector';\n\nexport function VariableTree() {\n const [posKey, setPosKey] = useState('');\n const [visible, setVisible] = useState(false);\n const [position, setPosition] = useState(-1);\n const editor = useEditor<EditorAPI>();\n\n function insert(variablePath: string) {\n const range = getCurrentMentionReplaceRange(editor.$view.state);\n\n if (!range) {\n return;\n }\n\n editor.replaceText({\n ...range,\n text: '{{' + variablePath + '}}',\n });\n\n setVisible(false);\n }\n\n function handleOpenChange(e: MentionOpenChangeEvent) {\n setPosition(e.state.selection.main.head);\n setVisible(e.value);\n }\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n }, [editor, visible]);\n\n const treeData = useVariableTree({});\n\n return (\n <>\n <Mention triggerCharacters={['@']} onOpenChange={handleOpenChange} />\n\n <Popover\n visible={visible}\n trigger=\"custom\"\n position=\"topLeft\"\n rePosKey={posKey}\n content={\n <div style={{ width: 300 }}>\n <Tree\n treeData={treeData}\n onSelect={(v) => {\n insert(v);\n }}\n />\n </div>\n }\n >\n {/* PositionMirror allows the Popover to appear at the specified cursor position */}\n <PositionMirror\n position={position}\n // When Doc scroll, update position\n onChange={() => setPosKey(String(Math.random()))}\n />\n </Popover>\n </>\n );\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useLayoutEffect } from 'react';\n\nimport { isEqual, last } from 'lodash-es';\nimport {\n BaseVariableField,\n Disposable,\n DisposableCollection,\n Scope,\n useCurrentScope,\n} from '@flowgram.ai/editor';\nimport { Popover } from '@douyinfe/semi-ui';\nimport { IconIssueStroked } from '@douyinfe/semi-icons';\nimport { useInjector } from '@coze-editor/editor/react';\nimport {\n Decoration,\n DecorationSet,\n EditorView,\n MatchDecorator,\n ViewPlugin,\n WidgetType,\n} from '@codemirror/view';\n\nimport { IPolyfillRoot, polyfillCreateRoot } from '@/shared';\n\nimport { UIPopoverContent, UIRootTitle, UITag, UIVarName } from '../styles';\n\nclass VariableTagWidget extends WidgetType {\n keyPath?: string[];\n\n toDispose = new DisposableCollection();\n\n scope: Scope;\n\n root: IPolyfillRoot;\n\n constructor({ keyPath, scope }: { keyPath?: string[]; scope: Scope }) {\n super();\n\n this.keyPath = keyPath;\n this.scope = scope;\n }\n\n renderIcon = (icon: string | JSX.Element) => {\n if (typeof icon === 'string') {\n return <img style={{ marginRight: 8 }} width={12} height={12} src={icon} />;\n }\n\n return icon;\n };\n\n renderVariable(v?: BaseVariableField) {\n if (!v) {\n this.root.render(\n <UITag prefixIcon={<IconIssueStroked />} color=\"amber\">\n Unknown\n </UITag>\n );\n return;\n }\n\n const rootField = last(v.parentFields);\n\n const rootTitle = (\n <UIRootTitle>{rootField?.meta.title ? `${rootField.meta.title} -` : ''}</UIRootTitle>\n );\n const rootIcon = this.renderIcon(rootField?.meta.icon);\n\n this.root.render(\n <Popover\n content={\n <UIPopoverContent>\n {rootIcon}\n {rootTitle}\n <UIVarName>{v?.keyPath.slice(1).join('.')}</UIVarName>\n </UIPopoverContent>\n }\n >\n <UITag prefixIcon={rootIcon}>\n {rootTitle}\n <UIVarName>{v?.key}</UIVarName>\n </UITag>\n </Popover>\n );\n }\n\n toDOM(view: EditorView): HTMLElement {\n const dom = document.createElement('span');\n\n this.root = polyfillCreateRoot(dom);\n\n this.toDispose.push(\n Disposable.create(() => {\n this.root.unmount();\n })\n );\n\n this.toDispose.push(\n this.scope.available.trackByKeyPath(\n this.keyPath,\n (v) => {\n this.renderVariable(v);\n },\n { triggerOnInit: false }\n )\n );\n\n this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));\n\n return dom;\n }\n\n eq(other: VariableTagWidget) {\n return isEqual(this.keyPath, other.keyPath);\n }\n\n ignoreEvent(): boolean {\n return false;\n }\n\n destroy(dom: HTMLElement): void {\n this.toDispose.dispose();\n }\n}\n\nexport function VariableTagInject() {\n const injector = useInjector();\n\n const scope = useCurrentScope();\n\n // 基于 {{var}} 的正则进行匹配,匹配后进行自定义渲染\n useLayoutEffect(() => {\n const atMatcher = new MatchDecorator({\n regexp: /\\{\\{([^\\}\\{]+)\\}\\}/g,\n decoration: (match) =>\n Decoration.replace({\n widget: new VariableTagWidget({\n keyPath: match[1]?.split('.') ?? [],\n scope,\n }),\n }),\n });\n\n return injector.inject([\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(private view: EditorView) {\n this.decorations = atMatcher.createDeco(view);\n }\n\n update() {\n this.decorations = atMatcher.createDeco(this.view);\n }\n },\n {\n decorations: (p) => p.decorations,\n provide(p) {\n return EditorView.atomicRanges.of(\n (view) => view.plugin(p)?.decorations ?? Decoration.none\n );\n },\n }\n ),\n ]);\n }, [injector]);\n\n return null;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport styled from 'styled-components';\nimport { Tag } from '@douyinfe/semi-ui';\n\nexport const UIRootTitle = styled.div`\n margin-right: 4px;\n min-width: 20px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--semi-color-text-2);\n`;\n\nexport const UIVarName = styled.div`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\nexport const UITag = styled(Tag)`\n display: inline-flex;\n align-items: center;\n justify-content: flex-start;\n max-width: 300px;\n\n & .semi-tag-content-center {\n justify-content: flex-start;\n }\n\n &.semi-tag {\n margin: 0 5px;\n }\n`;\n\nexport const UIPopoverContent = styled.div`\n padding: 10px;\n display: inline-flex;\n align-items: center;\n justify-content: flex-start;\n`;\n"],"mappings":";;;;;;;;;AAKA,OAAOA,YAAW;AAElB,SAAS,YAAY;AACrB,SAAS,0BAA0B;;;ACHnC,OAAO,SAAS,WAAW,gBAAgB;AAE3C,SAAS,SAAS,YAAY;AAC9B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,SAAS,eAAe;AAC7B,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,EAAE;AACvC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,EAAE;AAC3C,QAAM,SAAS,UAAqB;AAEpC,WAAS,OAAO,cAAsB;AACpC,UAAM,QAAQ,8BAA8B,OAAO,MAAM,KAAK;AAE9D,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,WAAO,YAAY;AAAA,MACjB,GAAG;AAAA,MACH,MAAM,OAAO,eAAe;AAAA,IAC9B,CAAC;AAED,eAAW,KAAK;AAAA,EA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AA,OAAA,cAAC,uBAAkB;AAAA,EACrB;AAEJ;","names":["React","React","Popover","React","Popover","React"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptEditor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-727SU246.js";
|
|
4
4
|
import {
|
|
5
5
|
FlowValueUtils
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DEZUEMUM.js";
|
|
7
7
|
|
|
8
8
|
// src/components/prompt-editor-with-inputs/editor.tsx
|
|
9
9
|
import React3 from "react";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
|
|
21
21
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
22
22
|
import React, { useMemo } from "react";
|
|
23
|
-
import { isPlainObject, last } from "lodash";
|
|
23
|
+
import { isPlainObject, last } from "lodash-es";
|
|
24
24
|
import {
|
|
25
25
|
ASTMatch,
|
|
26
26
|
useScopeAvailable
|
|
@@ -164,4 +164,4 @@ function PromptEditorWithInputs({
|
|
|
164
164
|
export {
|
|
165
165
|
PromptEditorWithInputs
|
|
166
166
|
};
|
|
167
|
-
//# sourceMappingURL=editor-
|
|
167
|
+
//# sourceMappingURL=editor-OXPGKPF5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/prompt-editor-with-inputs/editor.tsx","../../src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx","../../src/components/prompt-editor-with-inputs/inputs-picker.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';\n\nimport { InputsTree } from './extensions/inputs-tree';\n\nexport interface PromptEditorWithInputsProps extends PromptEditorPropsType {\n inputsValues: any;\n}\n\nexport function PromptEditorWithInputs({\n inputsValues,\n ...restProps\n}: PromptEditorWithInputsProps) {\n return (\n <PromptEditor {...restProps}>\n <InputsTree inputsValues={inputsValues} />\n </PromptEditor>\n );\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useEffect, useState } from 'react';\n\nimport { Popover } from '@douyinfe/semi-ui';\nimport {\n Mention,\n MentionOpenChangeEvent,\n getCurrentMentionReplaceRange,\n useEditor,\n PositionMirror,\n} from '@coze-editor/editor/react';\nimport { EditorAPI } from '@coze-editor/editor/preset-prompt';\n\nimport { IFlowValue } from '@/typings';\n\nimport { InputsPicker } from '../inputs-picker';\n\nexport function InputsTree({ inputsValues }: { inputsValues: Record<string, IFlowValue> }) {\n const [posKey, setPosKey] = useState('');\n const [visible, setVisible] = useState(false);\n const [position, setPosition] = useState(-1);\n const editor = useEditor<EditorAPI>();\n\n function insert(variablePath: string) {\n const range = getCurrentMentionReplaceRange(editor.$view.state);\n\n if (!range) {\n return;\n }\n\n /**\n * When user input {{xxxx}}, {{{xxx}}}(more brackets if possible), replace all brackets with {{xxxx}}\n */\n let { from, to } = range;\n while (editor.$view.state.doc.sliceString(from - 1, from) === '{') {\n from--;\n }\n while (editor.$view.state.doc.sliceString(to, to + 1) === '}') {\n to++;\n }\n\n editor.replaceText({\n ...range,\n text: '{{' + variablePath + '}}',\n });\n\n setVisible(false);\n }\n\n function handleOpenChange(e: MentionOpenChangeEvent) {\n setPosition(e.state.selection.main.head);\n setVisible(e.value);\n }\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n }, [editor, visible]);\n\n return (\n <>\n <Mention triggerCharacters={['{', '{}', '@']} onOpenChange={handleOpenChange} />\n\n <Popover\n visible={visible}\n trigger=\"custom\"\n position=\"topLeft\"\n rePosKey={posKey}\n content={\n <div style={{ width: 300 }}>\n <InputsPicker\n inputsValues={inputsValues}\n onSelect={(v) => {\n insert(v);\n }}\n />\n </div>\n }\n >\n {/* PositionMirror allows the Popover to appear at the specified cursor position */}\n <PositionMirror\n position={position}\n // When Doc scroll, update position\n onChange={() => setPosKey(String(Math.random()))}\n />\n </Popover>\n </>\n );\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useMemo } from 'react';\n\nimport { isPlainObject, last } from 'lodash-es';\nimport {\n type ArrayType,\n ASTMatch,\n type BaseType,\n type BaseVariableField,\n useScopeAvailable,\n} from '@flowgram.ai/editor';\nimport { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';\nimport { Tree } from '@douyinfe/semi-ui';\n\nimport { FlowValueUtils } from '@/shared';\n\ntype VariableField = BaseVariableField<{ icon?: string | JSX.Element; title?: string }>;\n\nexport function InputsPicker({\n inputsValues,\n onSelect,\n}: {\n inputsValues: any;\n onSelect: (v: string) => void;\n}) {\n const available = useScopeAvailable();\n\n const getArrayDrilldown = (type: ArrayType, depth = 1): { type: BaseType; depth: number } => {\n if (ASTMatch.isArray(type.items)) {\n return getArrayDrilldown(type.items, depth + 1);\n }\n\n return { type: type.items, depth: depth };\n };\n\n const renderVariable = (variable: VariableField, keyPath: string[]): TreeNodeData => {\n let type = variable?.type;\n\n let children: TreeNodeData[] | undefined;\n\n if (ASTMatch.isObject(type)) {\n children = (type.properties || [])\n .map((_property) => renderVariable(_property as VariableField, [...keyPath, _property.key]))\n .filter(Boolean) as TreeNodeData[];\n }\n\n if (ASTMatch.isArray(type)) {\n const drilldown = getArrayDrilldown(type);\n\n if (ASTMatch.isObject(drilldown.type)) {\n children = (drilldown.type.properties || [])\n .map((_property) =>\n renderVariable(_property as VariableField, [\n ...keyPath,\n ...new Array(drilldown.depth).fill('[0]'),\n _property.key,\n ])\n )\n .filter(Boolean) as TreeNodeData[];\n }\n }\n\n const key = keyPath\n .map((_key, idx) => (_key === '[0]' || idx === 0 ? _key : `.${_key}`))\n .join('');\n\n return {\n key: key,\n label: last(keyPath),\n value: key,\n children,\n };\n };\n\n const getTreeData = (value: any, keyPath: string[]): TreeNodeData | undefined => {\n const currKey = keyPath.join('.');\n\n if (FlowValueUtils.isFlowValue(value)) {\n if (FlowValueUtils.isRef(value)) {\n const variable = available.getByKeyPath(value.content || []);\n if (variable) {\n return renderVariable(variable, keyPath);\n }\n }\n return {\n key: currKey,\n value: currKey,\n label: last(keyPath),\n };\n }\n\n if (isPlainObject(value)) {\n return {\n key: currKey,\n value: currKey,\n label: last(keyPath),\n children: Object.entries(value)\n .map(([key, value]) => getTreeData(value, [...keyPath, key])!)\n .filter(Boolean),\n };\n }\n };\n\n const treeData: TreeNodeData[] = useMemo(\n () =>\n Object.entries(inputsValues)\n .map(([key, value]) => getTreeData(value, [key])!)\n .filter(Boolean),\n []\n );\n\n return <Tree treeData={treeData} onSelect={(v) => onSelect(v)} />;\n}\n"],"mappings":";;;;;;;;AAKA,OAAOA,YAAW;;;ACAlB,OAAOC,UAAS,WAAW,gBAAgB;AAE3C,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACTP,OAAO,SAAS,eAAe;AAE/B,SAAS,eAAe,YAAY;AACpC;AAAA,EAEE;AAAA,EAGA;AAAA,OACK;AAEP,SAAS,YAAY;AAMd,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAGG;AACD,QAAM,YAAY,kBAAkB;AAEpC,QAAM,oBAAoB,CAAC,MAAiB,QAAQ,MAAyC;AAC3F,QAAI,SAAS,QAAQ,KAAK,KAAK,GAAG;AAChC,aAAO,kBAAkB,KAAK,OAAO,QAAQ,CAAC;AAAA,IAChD;AAEA,WAAO,EAAE,MAAM,KAAK,OAAO,MAAa;AAAA,EAC1C;AAEA,QAAM,iBAAiB,CAAC,UAAyB,YAAoC;AACnF,QAAI,OAAO,UAAU;AAErB,QAAI;AAEJ,QAAI,SAAS,SAAS,IAAI,GAAG;AAC3B,kBAAY,KAAK,cAAc,CAAC,GAC7B,IAAI,CAAC,cAAc,eAAe,WAA4B,CAAC,GAAG,SAAS,UAAU,G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AAC,WAAQ,mBAAmB,CAAC,KAAK,MAAM,GAAG,GAAG,cAAc,kBAAkB,GAE9E,gBAAAA,OAAA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAQ;AAAA,MACR,UAAS;AAAA,MACT,UAAU;AAAA,MACV,SACE,gBAAAA,OAAA,cAAC,SAAI,OAAO,EAAE,OAAO,IAAI,KACvB,gBAAAA,OAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,UAAU,CAAC,MAAM;AACf,mBAAO,CAAC;AAAA,UACV;AAAA;AAAA,MACF,CACF;AAAA;AAAA,IAIF,gBAAAA,OAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QAEA,UAAU,MAAM,UAAU,OAAO,KAAK,OAAO,CAAC,CAAC;AAAA;AAAA,IACjD;AAAA,EACF,CACF;AAEJ;;;AD9EO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA,GAAG;AACL,GAAgC;AAC9B,SACE,gBAAAC,OAAA,cAAC,gBAAc,GAAG,aAChB,gBAAAA,OAAA,cAAC,cAAW,cAA4B,CAC1C;AAEJ;","names":["React","React","value","React","React"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptEditor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-727SU246.js";
|
|
4
4
|
import {
|
|
5
5
|
useVariableTree
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IHOHRV5V.js";
|
|
7
7
|
import {
|
|
8
8
|
polyfillCreateRoot
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DEZUEMUM.js";
|
|
10
10
|
|
|
11
11
|
// src/components/prompt-editor-with-variables/editor.tsx
|
|
12
12
|
import React3 from "react";
|
|
@@ -83,7 +83,7 @@ function VariableTree() {
|
|
|
83
83
|
|
|
84
84
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
85
85
|
import React2, { useLayoutEffect } from "react";
|
|
86
|
-
import { isEqual, last } from "lodash";
|
|
86
|
+
import { isEqual, last } from "lodash-es";
|
|
87
87
|
import {
|
|
88
88
|
Disposable,
|
|
89
89
|
DisposableCollection,
|
|
@@ -246,4 +246,4 @@ function PromptEditorWithVariables(props) {
|
|
|
246
246
|
export {
|
|
247
247
|
PromptEditorWithVariables
|
|
248
248
|
};
|
|
249
|
-
//# sourceMappingURL=editor-
|
|
249
|
+
//# sourceMappingURL=editor-Z24WLBPO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/prompt-editor-with-variables/editor.tsx","../../src/components/prompt-editor-with-variables/extensions/variable-tree.tsx","../../src/components/prompt-editor-with-variables/extensions/variable-tag.tsx","../../src/components/prompt-editor-with-variables/styles.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';\n\nimport { VariableTree } from './extensions/variable-tree';\nimport { VariableTagInject } from './extensions/variable-tag';\n\nexport interface PromptEditorWithVariablesProps extends PromptEditorPropsType {}\n\nexport function PromptEditorWithVariables(props: PromptEditorWithVariablesProps) {\n return (\n <PromptEditor {...props}>\n <VariableTree />\n <VariableTagInject />\n </PromptEditor>\n );\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useEffect, useState } from 'react';\n\nimport { Popover, Tree } from '@douyinfe/semi-ui';\nimport {\n Mention,\n MentionOpenChangeEvent,\n getCurrentMentionReplaceRange,\n useEditor,\n PositionMirror,\n} from '@coze-editor/editor/react';\nimport { EditorAPI } from '@coze-editor/editor/preset-prompt';\n\nimport { useVariableTree } from '@/components/variable-selector';\n\nexport function VariableTree() {\n const [posKey, setPosKey] = useState('');\n const [visible, setVisible] = useState(false);\n const [position, setPosition] = useState(-1);\n const editor = useEditor<EditorAPI>();\n\n function insert(variablePath: string) {\n const range = getCurrentMentionReplaceRange(editor.$view.state);\n\n if (!range) {\n return;\n }\n\n /**\n * When user input {{xxxx}}, {{{xxx}}}(more brackets if possible), replace all brackets with {{xxxx}}\n */\n let { from, to } = range;\n while (editor.$view.state.doc.sliceString(from - 1, from) === '{') {\n from--;\n }\n while (editor.$view.state.doc.sliceString(to, to + 1) === '}') {\n to++;\n }\n\n editor.replaceText({\n from,\n to,\n text: '{{' + variablePath + '}}',\n });\n\n setVisible(false);\n }\n\n function handleOpenChange(e: MentionOpenChangeEvent) {\n setPosition(e.state.selection.main.head);\n setVisible(e.value);\n }\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n }, [editor, visible]);\n\n const treeData = useVariableTree({});\n\n return (\n <>\n <Mention triggerCharacters={['{', '{}', '@']} onOpenChange={handleOpenChange} />\n\n <Popover\n visible={visible}\n trigger=\"custom\"\n position=\"topLeft\"\n rePosKey={posKey}\n content={\n <div style={{ width: 300 }}>\n <Tree\n treeData={treeData}\n onSelect={(v) => {\n insert(v);\n }}\n />\n </div>\n }\n >\n {/* PositionMirror allows the Popover to appear at the specified cursor position */}\n <PositionMirror\n position={position}\n // When Doc scroll, update position\n onChange={() => setPosKey(String(Math.random()))}\n />\n </Popover>\n </>\n );\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useLayoutEffect } from 'react';\n\nimport { isEqual, last } from 'lodash-es';\nimport {\n BaseVariableField,\n Disposable,\n DisposableCollection,\n Scope,\n useCurrentScope,\n} from '@flowgram.ai/editor';\nimport { Popover } from '@douyinfe/semi-ui';\nimport { IconIssueStroked } from '@douyinfe/semi-icons';\nimport { useInjector } from '@coze-editor/editor/react';\nimport {\n Decoration,\n DecorationSet,\n EditorView,\n MatchDecorator,\n ViewPlugin,\n WidgetType,\n} from '@codemirror/view';\n\nimport { IPolyfillRoot, polyfillCreateRoot } from '@/shared';\n\nimport { UIPopoverContent, UIRootTitle, UITag, UIVarName } from '../styles';\n\nclass VariableTagWidget extends WidgetType {\n keyPath?: string[];\n\n toDispose = new DisposableCollection();\n\n scope: Scope;\n\n root: IPolyfillRoot;\n\n constructor({ keyPath, scope }: { keyPath?: string[]; scope: Scope }) {\n super();\n\n this.keyPath = keyPath;\n this.scope = scope;\n }\n\n renderIcon = (icon: string | JSX.Element) => {\n if (typeof icon === 'string') {\n return <img style={{ marginRight: 8 }} width={12} height={12} src={icon} />;\n }\n\n return icon;\n };\n\n renderVariable(v?: BaseVariableField) {\n if (!v) {\n this.root.render(\n <UITag prefixIcon={<IconIssueStroked />} color=\"amber\">\n Unknown\n </UITag>\n );\n return;\n }\n\n const rootField = last(v.parentFields);\n\n const rootTitle = (\n <UIRootTitle>{rootField?.meta.title ? `${rootField.meta.title} -` : ''}</UIRootTitle>\n );\n const rootIcon = this.renderIcon(rootField?.meta.icon);\n\n this.root.render(\n <Popover\n content={\n <UIPopoverContent>\n {rootIcon}\n {rootTitle}\n <UIVarName>{v?.keyPath.slice(1).join('.')}</UIVarName>\n </UIPopoverContent>\n }\n >\n <UITag prefixIcon={rootIcon}>\n {rootTitle}\n <UIVarName>{v?.key}</UIVarName>\n </UITag>\n </Popover>\n );\n }\n\n toDOM(view: EditorView): HTMLElement {\n const dom = document.createElement('span');\n\n this.root = polyfillCreateRoot(dom);\n\n this.toDispose.push(\n Disposable.create(() => {\n this.root.unmount();\n })\n );\n\n this.toDispose.push(\n this.scope.available.trackByKeyPath(\n this.keyPath,\n (v) => {\n this.renderVariable(v);\n },\n { triggerOnInit: false }\n )\n );\n\n this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));\n\n return dom;\n }\n\n eq(other: VariableTagWidget) {\n return isEqual(this.keyPath, other.keyPath);\n }\n\n ignoreEvent(): boolean {\n return false;\n }\n\n destroy(dom: HTMLElement): void {\n this.toDispose.dispose();\n }\n}\n\nexport function VariableTagInject() {\n const injector = useInjector();\n\n const scope = useCurrentScope();\n\n // 基于 {{var}} 的正则进行匹配,匹配后进行自定义渲染\n useLayoutEffect(() => {\n const atMatcher = new MatchDecorator({\n regexp: /\\{\\{([^\\}\\{]+)\\}\\}/g,\n decoration: (match) =>\n Decoration.replace({\n widget: new VariableTagWidget({\n keyPath: match[1]?.split('.') ?? [],\n scope,\n }),\n }),\n });\n\n return injector.inject([\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(private view: EditorView) {\n this.decorations = atMatcher.createDeco(view);\n }\n\n update() {\n this.decorations = atMatcher.createDeco(this.view);\n }\n },\n {\n decorations: (p) => p.decorations,\n provide(p) {\n return EditorView.atomicRanges.of(\n (view) => view.plugin(p)?.decorations ?? Decoration.none\n );\n },\n }\n ),\n ]);\n }, [injector]);\n\n return null;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport styled from 'styled-components';\nimport { Tag } from '@douyinfe/semi-ui';\n\nexport const UIRootTitle = styled.div`\n margin-right: 4px;\n min-width: 20px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--semi-color-text-2);\n`;\n\nexport const UIVarName = styled.div`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\nexport const UITag = styled(Tag)`\n display: inline-flex;\n align-items: center;\n justify-content: flex-start;\n max-width: 300px;\n\n & .semi-tag-content-center {\n justify-content: flex-start;\n }\n\n &.semi-tag {\n margin: 0 5px;\n }\n`;\n\nexport const UIPopoverContent = styled.div`\n padding: 10px;\n display: inline-flex;\n align-items: center;\n justify-content: flex-start;\n`;\n"],"mappings":";;;;;;;;;;;AAKA,OAAOA,YAAW;;;ACAlB,OAAO,SAAS,WAAW,gBAAgB;AAE3C,SAAS,SAAS,YAAY;AAC9B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,SAAS,eAAe;AAC7B,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS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