@flowgram-vue/form-materials 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/LICENSE +22 -0
  2. package/bin/run.sh +7 -0
  3. package/dist/index.cjs +0 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +0 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +86 -0
  9. package/src/components/assign-row/assign-row.vue +69 -0
  10. package/src/components/assign-row/index.ts +7 -0
  11. package/src/components/assign-row/types.ts +25 -0
  12. package/src/components/assign-rows/assign-rows.vue +44 -0
  13. package/src/components/assign-rows/index.ts +6 -0
  14. package/src/components/batch-outputs/batch-outputs.vue +46 -0
  15. package/src/components/batch-outputs/index.ts +6 -0
  16. package/src/components/batch-outputs/styles.css +17 -0
  17. package/src/components/batch-outputs/types.ts +23 -0
  18. package/src/components/batch-variable-selector/batch-variable-selector.vue +24 -0
  19. package/src/components/batch-variable-selector/index.ts +6 -0
  20. package/src/components/blur-input/blur-input.vue +47 -0
  21. package/src/components/blur-input/index.ts +6 -0
  22. package/src/components/code-editor/base-code-editor.vue +44 -0
  23. package/src/components/code-editor/index.ts +58 -0
  24. package/src/components/code-editor/styles.css +27 -0
  25. package/src/components/code-editor/types.ts +20 -0
  26. package/src/components/code-editor/utils.ts +24 -0
  27. package/src/components/code-editor-mini/code-editor-mini.vue +16 -0
  28. package/src/components/code-editor-mini/index.ts +6 -0
  29. package/src/components/condition-context/context.ts +45 -0
  30. package/src/components/condition-context/hooks/use-condition.ts +120 -0
  31. package/src/components/condition-context/index.ts +14 -0
  32. package/src/components/condition-context/op.ts +86 -0
  33. package/src/components/condition-context/types.ts +22 -0
  34. package/src/components/condition-row/condition-row.vue +126 -0
  35. package/src/components/condition-row/index.ts +7 -0
  36. package/src/components/condition-row/styles.css +30 -0
  37. package/src/components/condition-row/types.ts +12 -0
  38. package/src/components/constant-input/constant-input.vue +48 -0
  39. package/src/components/constant-input/index.ts +7 -0
  40. package/src/components/constant-input/types.ts +23 -0
  41. package/src/components/coze-editor-extensions/extensions/inputs-tree.vue +16 -0
  42. package/src/components/coze-editor-extensions/extensions/variable-tag.vue +10 -0
  43. package/src/components/coze-editor-extensions/extensions/variable-tree.vue +18 -0
  44. package/src/components/coze-editor-extensions/index.ts +22 -0
  45. package/src/components/coze-editor-extensions/styles.css +41 -0
  46. package/src/components/db-condition-row/db-condition-row.vue +112 -0
  47. package/src/components/db-condition-row/index.ts +7 -0
  48. package/src/components/db-condition-row/styles.css +41 -0
  49. package/src/components/db-condition-row/types.ts +20 -0
  50. package/src/components/display-flow-value/display-flow-value.vue +46 -0
  51. package/src/components/display-flow-value/index.ts +6 -0
  52. package/src/components/display-inputs-values/display-inputs-value-all-in-tag.vue +26 -0
  53. package/src/components/display-inputs-values/display-inputs-values.vue +43 -0
  54. package/src/components/display-inputs-values/index.ts +7 -0
  55. package/src/components/display-inputs-values/styles.css +10 -0
  56. package/src/components/display-outputs/display-outputs.vue +62 -0
  57. package/src/components/display-outputs/index.ts +6 -0
  58. package/src/components/display-outputs/styles.css +10 -0
  59. package/src/components/display-schema-tag/display-schema-tag.vue +41 -0
  60. package/src/components/display-schema-tag/index.ts +6 -0
  61. package/src/components/display-schema-tag/styles.css +25 -0
  62. package/src/components/display-schema-tree/display-schema-tree.vue +55 -0
  63. package/src/components/display-schema-tree/index.ts +6 -0
  64. package/src/components/display-schema-tree/styles.css +84 -0
  65. package/src/components/dynamic-value-input/dynamic-value-input.vue +145 -0
  66. package/src/components/dynamic-value-input/hooks.ts +71 -0
  67. package/src/components/dynamic-value-input/index.ts +10 -0
  68. package/src/components/dynamic-value-input/styles.css +59 -0
  69. package/src/components/index.ts +84 -0
  70. package/src/components/inputs-values/index.ts +6 -0
  71. package/src/components/inputs-values/inputs-values.vue +67 -0
  72. package/src/components/inputs-values/styles.css +17 -0
  73. package/src/components/inputs-values/types.ts +23 -0
  74. package/src/components/inputs-values-tree/hooks/use-child-list.ts +65 -0
  75. package/src/components/inputs-values-tree/index.ts +6 -0
  76. package/src/components/inputs-values-tree/inputs-values-tree.vue +59 -0
  77. package/src/components/inputs-values-tree/row.vue +139 -0
  78. package/src/components/inputs-values-tree/styles.css +94 -0
  79. package/src/components/inputs-values-tree/types.ts +23 -0
  80. package/src/components/json-editor-with-variables/index.ts +7 -0
  81. package/src/components/json-editor-with-variables/json-editor-with-variables.vue +24 -0
  82. package/src/components/json-editor-with-variables/types.ts +8 -0
  83. package/src/components/json-schema-creator/index.ts +7 -0
  84. package/src/components/json-schema-creator/json-input-modal.vue +51 -0
  85. package/src/components/json-schema-creator/json-schema-creator.vue +27 -0
  86. package/src/components/json-schema-creator/types.ts +10 -0
  87. package/src/components/json-schema-creator/utils/json-to-schema.ts +50 -0
  88. package/src/components/json-schema-editor/default-value.vue +30 -0
  89. package/src/components/json-schema-editor/hooks.ts +134 -0
  90. package/src/components/json-schema-editor/index.ts +6 -0
  91. package/src/components/json-schema-editor/json-schema-editor.vue +53 -0
  92. package/src/components/json-schema-editor/property-edit.vue +222 -0
  93. package/src/components/json-schema-editor/styles.css +135 -0
  94. package/src/components/json-schema-editor/types.ts +25 -0
  95. package/src/components/prompt-editor/index.ts +7 -0
  96. package/src/components/prompt-editor/prompt-editor.vue +40 -0
  97. package/src/components/prompt-editor/styles.css +14 -0
  98. package/src/components/prompt-editor/types.ts +20 -0
  99. package/src/components/prompt-editor-with-inputs/index.ts +7 -0
  100. package/src/components/prompt-editor-with-inputs/prompt-editor-with-inputs.vue +18 -0
  101. package/src/components/prompt-editor-with-inputs/types.ts +11 -0
  102. package/src/components/prompt-editor-with-variables/index.ts +7 -0
  103. package/src/components/prompt-editor-with-variables/prompt-editor-with-variables.vue +19 -0
  104. package/src/components/prompt-editor-with-variables/types.ts +8 -0
  105. package/src/components/sql-editor-with-variables/index.ts +7 -0
  106. package/src/components/sql-editor-with-variables/sql-editor-with-variables.vue +24 -0
  107. package/src/components/sql-editor-with-variables/types.ts +8 -0
  108. package/src/components/type-selector/index.ts +11 -0
  109. package/src/components/type-selector/type-selector.vue +79 -0
  110. package/src/components/type-selector/types.ts +33 -0
  111. package/src/components/variable-selector/context.ts +44 -0
  112. package/src/components/variable-selector/index.ts +13 -0
  113. package/src/components/variable-selector/styles.css +70 -0
  114. package/src/components/variable-selector/types.ts +22 -0
  115. package/src/components/variable-selector/use-variable-tree.ts +108 -0
  116. package/src/components/variable-selector/variable-selector.vue +139 -0
  117. package/src/effects/auto-rename-ref/index.ts +109 -0
  118. package/src/effects/index.ts +12 -0
  119. package/src/effects/listen-ref-schema-change/index.ts +56 -0
  120. package/src/effects/listen-ref-value-change/index.ts +53 -0
  121. package/src/effects/provide-batch-input/index.ts +40 -0
  122. package/src/effects/provide-json-schema-outputs/index.ts +23 -0
  123. package/src/effects/sync-variable-title/index.ts +25 -0
  124. package/src/effects/validate-when-variable-sync/index.ts +34 -0
  125. package/src/env.d.ts +12 -0
  126. package/src/form-plugins/batch-outputs-plugin/index.ts +120 -0
  127. package/src/form-plugins/index.ts +8 -0
  128. package/src/form-plugins/infer-assign-plugin/index.ts +87 -0
  129. package/src/form-plugins/infer-inputs-plugin/index.ts +85 -0
  130. package/src/hooks/index.ts +6 -0
  131. package/src/hooks/use-object-list/index.ts +161 -0
  132. package/src/index.ts +125 -0
  133. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +27 -0
  134. package/src/plugins/disable-declaration-plugin/index.ts +6 -0
  135. package/src/plugins/index.ts +16 -0
  136. package/src/plugins/json-schema-preset/create-type-preset-plugin.ts +35 -0
  137. package/src/plugins/json-schema-preset/index.ts +25 -0
  138. package/src/plugins/json-schema-preset/type-definition/array.ts +38 -0
  139. package/src/plugins/json-schema-preset/type-definition/boolean.ts +47 -0
  140. package/src/plugins/json-schema-preset/type-definition/date-time.ts +60 -0
  141. package/src/plugins/json-schema-preset/type-definition/enum.ts +31 -0
  142. package/src/plugins/json-schema-preset/type-definition/index.ts +37 -0
  143. package/src/plugins/json-schema-preset/type-definition/integer.ts +47 -0
  144. package/src/plugins/json-schema-preset/type-definition/map.ts +34 -0
  145. package/src/plugins/json-schema-preset/type-definition/number.ts +46 -0
  146. package/src/plugins/json-schema-preset/type-definition/object.ts +34 -0
  147. package/src/plugins/json-schema-preset/type-definition/string.ts +52 -0
  148. package/src/plugins/json-schema-preset/types.ts +25 -0
  149. package/src/plugins/json-schema-preset/vue.ts +38 -0
  150. package/src/shared/flow-value/index.ts +17 -0
  151. package/src/shared/flow-value/schema.ts +38 -0
  152. package/src/shared/flow-value/types.ts +49 -0
  153. package/src/shared/flow-value/utils.ts +213 -0
  154. package/src/shared/format-legacy-refs/index.ts +158 -0
  155. package/src/shared/format-legacy-refs/readme.md +38 -0
  156. package/src/shared/index.ts +32 -0
  157. package/src/shared/inject-material/index.ts +50 -0
  158. package/src/shared/lazy-suspense/index.ts +20 -0
  159. package/src/shared/polyfill-create-root/index.ts +38 -0
  160. package/src/ui/fg-button.vue +27 -0
  161. package/src/ui/fg-cascader.vue +92 -0
  162. package/src/ui/fg-checkbox.vue +25 -0
  163. package/src/ui/fg-icon-button.vue +31 -0
  164. package/src/ui/fg-input.vue +50 -0
  165. package/src/ui/fg-modal.vue +37 -0
  166. package/src/ui/fg-popover.vue +19 -0
  167. package/src/ui/fg-select.vue +81 -0
  168. package/src/ui/fg-tag.vue +37 -0
  169. package/src/ui/fg-textarea.vue +42 -0
  170. package/src/ui/fg-tree-nodes.vue +48 -0
  171. package/src/ui/fg-tree-select.vue +86 -0
  172. package/src/ui/icons.ts +60 -0
  173. package/src/ui/index.ts +20 -0
  174. package/src/ui/styles.css +277 -0
  175. package/src/ui/types.ts +36 -0
  176. package/src/validate/index.ts +6 -0
  177. package/src/validate/validate-flow-value/index.ts +62 -0
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { createApp, type App, type VNode } from 'vue';
7
+
8
+ export interface IPolyfillRoot {
9
+ render(children: VNode): void;
10
+ unmount(): void;
11
+ }
12
+
13
+ let unstableCreateRoot = (dom: HTMLElement): IPolyfillRoot => {
14
+ let app: App | null = null;
15
+ return {
16
+ render(children: VNode) {
17
+ if (app) {
18
+ app.unmount();
19
+ }
20
+ app = createApp({
21
+ render: () => children,
22
+ });
23
+ app.mount(dom);
24
+ },
25
+ unmount() {
26
+ app?.unmount();
27
+ app = null;
28
+ },
29
+ };
30
+ };
31
+
32
+ export function polyfillCreateRoot(dom: HTMLElement): IPolyfillRoot {
33
+ return unstableCreateRoot(dom);
34
+ }
35
+
36
+ export function unstableSetCreateRoot(createRoot: (dom: HTMLElement) => IPolyfillRoot) {
37
+ unstableCreateRoot = createRoot;
38
+ }
@@ -0,0 +1,27 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ defineProps<{
8
+ disabled?: boolean;
9
+ borderless?: boolean;
10
+ }>();
11
+
12
+ const emit = defineEmits<{
13
+ click: [event: MouseEvent];
14
+ }>();
15
+ </script>
16
+
17
+ <template>
18
+ <button
19
+ type="button"
20
+ class="fg-btn"
21
+ :class="{ borderless }"
22
+ :disabled="disabled"
23
+ @click="emit('click', $event)"
24
+ >
25
+ <slot />
26
+ </button>
27
+ </template>
@@ -0,0 +1,92 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { computed, onBeforeUnmount, onMounted, ref, type VNode } from 'vue';
8
+
9
+ import type { FgCascaderOption } from './types';
10
+
11
+ const props = withDefaults(
12
+ defineProps<{
13
+ options?: FgCascaderOption[];
14
+ value?: string[];
15
+ disabled?: boolean;
16
+ triggerRender?: () => VNode;
17
+ }>(),
18
+ { options: () => [] }
19
+ );
20
+
21
+ const emit = defineEmits<{
22
+ change: [value: string[]];
23
+ }>();
24
+
25
+ const open = ref(false);
26
+ const rootRef = ref<HTMLElement | null>(null);
27
+ const path = ref<string[]>(props.value || []);
28
+
29
+ const level0 = computed(() => props.options);
30
+ const level1 = computed(() => {
31
+ const current = props.options.find((item) => item.value === path.value[0]);
32
+ return current?.children || [];
33
+ });
34
+
35
+ const onDocClick = (event: MouseEvent) => {
36
+ if (rootRef.value && !rootRef.value.contains(event.target as Node)) {
37
+ open.value = false;
38
+ }
39
+ };
40
+
41
+ onMounted(() => document.addEventListener('mousedown', onDocClick));
42
+ onBeforeUnmount(() => document.removeEventListener('mousedown', onDocClick));
43
+
44
+ const pick = (level: number, value: string) => {
45
+ const next = [...path.value];
46
+ next[level] = value;
47
+ next.splice(level + 1);
48
+ path.value = next;
49
+ const option = (level === 0 ? level0.value : level1.value).find((item) => item.value === value);
50
+ if (!option?.children?.length) {
51
+ emit('change', next);
52
+ open.value = false;
53
+ }
54
+ };
55
+ </script>
56
+
57
+ <template>
58
+ <div ref="rootRef" class="fg-select-wrap">
59
+ <div @click="!disabled && (open = !open)">
60
+ <component :is="triggerRender" v-if="triggerRender" />
61
+ <button v-else type="button" class="fg-select" :disabled="disabled">
62
+ {{ (value || []).join(' / ') }}
63
+ </button>
64
+ </div>
65
+ <div v-if="open" class="fg-cascader-dropdown" style="display: flex; min-width: 240px">
66
+ <div style="flex: 1">
67
+ <button
68
+ v-for="option in level0"
69
+ :key="option.value"
70
+ type="button"
71
+ class="fg-cascader-option"
72
+ @click="pick(0, option.value)"
73
+ >
74
+ <component :is="option.label" v-if="typeof option.label !== 'string'" />
75
+ <span v-else>{{ option.label }}</span>
76
+ </button>
77
+ </div>
78
+ <div v-if="level1.length" style="flex: 1; border-left: 1px solid #e5e6eb">
79
+ <button
80
+ v-for="option in level1"
81
+ :key="option.value"
82
+ type="button"
83
+ class="fg-cascader-option"
84
+ @click="pick(1, option.value)"
85
+ >
86
+ <component :is="option.label" v-if="typeof option.label !== 'string'" />
87
+ <span v-else>{{ option.label }}</span>
88
+ </button>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </template>
@@ -0,0 +1,25 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ defineProps<{
8
+ checked?: boolean;
9
+ disabled?: boolean;
10
+ }>();
11
+
12
+ const emit = defineEmits<{
13
+ change: [checked: boolean];
14
+ }>();
15
+ </script>
16
+
17
+ <template>
18
+ <input
19
+ class="fg-checkbox"
20
+ type="checkbox"
21
+ :checked="checked"
22
+ :disabled="disabled"
23
+ @change="emit('change', ($event.target as HTMLInputElement).checked)"
24
+ />
25
+ </template>
@@ -0,0 +1,31 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import type { CSSProperties, VNode } from 'vue';
8
+
9
+ defineProps<{
10
+ disabled?: boolean;
11
+ icon?: VNode;
12
+ style?: CSSProperties;
13
+ }>();
14
+
15
+ const emit = defineEmits<{
16
+ click: [event: MouseEvent];
17
+ }>();
18
+ </script>
19
+
20
+ <template>
21
+ <button
22
+ type="button"
23
+ class="fg-icon-btn"
24
+ :disabled="disabled"
25
+ :style="style"
26
+ @click="emit('click', $event)"
27
+ >
28
+ <component :is="icon" v-if="icon" />
29
+ <slot />
30
+ </button>
31
+ </template>
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { computed, type CSSProperties } from 'vue';
8
+
9
+ const props = defineProps<{
10
+ modelValue?: string | number;
11
+ value?: string | number;
12
+ disabled?: boolean;
13
+ placeholder?: string;
14
+ style?: CSSProperties;
15
+ type?: string;
16
+ error?: boolean;
17
+ }>();
18
+
19
+ const emit = defineEmits<{
20
+ 'update:modelValue': [value: string];
21
+ change: [value: string];
22
+ blur: [event: FocusEvent];
23
+ focus: [event: FocusEvent];
24
+ }>();
25
+
26
+ const innerValue = computed(() =>
27
+ props.modelValue !== undefined ? props.modelValue : props.value
28
+ );
29
+
30
+ const onInput = (event: Event) => {
31
+ const next = (event.target as HTMLInputElement).value;
32
+ emit('update:modelValue', next);
33
+ emit('change', next);
34
+ };
35
+ </script>
36
+
37
+ <template>
38
+ <input
39
+ class="fg-input"
40
+ :class="{ error }"
41
+ :type="type || 'text'"
42
+ :value="innerValue"
43
+ :disabled="disabled"
44
+ :placeholder="placeholder"
45
+ :style="style"
46
+ @input="onInput"
47
+ @blur="emit('blur', $event)"
48
+ @focus="emit('focus', $event)"
49
+ />
50
+ </template>
@@ -0,0 +1,37 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ defineProps<{
10
+ visible?: boolean;
11
+ title?: string;
12
+ okText?: string;
13
+ cancelText?: string;
14
+ }>();
15
+
16
+ const emit = defineEmits<{
17
+ close: [];
18
+ confirm: [];
19
+ }>();
20
+ </script>
21
+
22
+ <template>
23
+ <div v-if="visible" class="fg-modal-mask" @click.self="emit('close')">
24
+ <div class="fg-modal">
25
+ <div class="fg-modal-title">{{ title }}</div>
26
+ <slot />
27
+ <div class="fg-modal-actions">
28
+ <button type="button" class="fg-btn" @click="emit('close')">
29
+ {{ cancelText || I18n.t('Cancel') }}
30
+ </button>
31
+ <button type="button" class="fg-btn" @click="emit('confirm')">
32
+ {{ okText || I18n.t('Generate') }}
33
+ </button>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </template>
@@ -0,0 +1,19 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { ref } from 'vue';
8
+
9
+ const hover = ref(false);
10
+ </script>
11
+
12
+ <template>
13
+ <div class="fg-popover" @mouseenter="hover = true" @mouseleave="hover = false">
14
+ <slot />
15
+ <div v-if="hover" class="fg-popover-content">
16
+ <slot name="content" />
17
+ </div>
18
+ </div>
19
+ </template>
@@ -0,0 +1,81 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
8
+
9
+ import type { FgSelectOption } from './types';
10
+
11
+ const props = withDefaults(
12
+ defineProps<{
13
+ modelValue?: string | number;
14
+ value?: string | number;
15
+ options?: FgSelectOption[];
16
+ disabled?: boolean;
17
+ placeholder?: string;
18
+ compact?: boolean;
19
+ }>(),
20
+ { options: () => [] }
21
+ );
22
+
23
+ const emit = defineEmits<{
24
+ 'update:modelValue': [value: string | number];
25
+ change: [value: string | number];
26
+ }>();
27
+
28
+ const open = ref(false);
29
+ const rootRef = ref<HTMLElement | null>(null);
30
+ const innerValue = computed(() =>
31
+ props.modelValue !== undefined ? props.modelValue : props.value
32
+ );
33
+
34
+ const selected = computed(() => props.options.find((item) => item.value === innerValue.value));
35
+
36
+ const onDocClick = (event: MouseEvent) => {
37
+ if (rootRef.value && !rootRef.value.contains(event.target as Node)) {
38
+ open.value = false;
39
+ }
40
+ };
41
+
42
+ onMounted(() => document.addEventListener('mousedown', onDocClick));
43
+ onBeforeUnmount(() => document.removeEventListener('mousedown', onDocClick));
44
+
45
+ const select = (option: FgSelectOption) => {
46
+ if (option.disabled) {
47
+ return;
48
+ }
49
+ emit('update:modelValue', option.value);
50
+ emit('change', option.value);
51
+ open.value = false;
52
+ };
53
+ </script>
54
+
55
+ <template>
56
+ <div ref="rootRef" class="fg-select-wrap">
57
+ <button
58
+ type="button"
59
+ class="fg-select"
60
+ :disabled="disabled"
61
+ @click="!disabled && (open = !open)"
62
+ >
63
+ <slot name="trigger" :value="innerValue" :option="selected">
64
+ {{ selected?.label || placeholder || '' }}
65
+ </slot>
66
+ </button>
67
+ <div v-if="open" class="fg-cascader-dropdown">
68
+ <button
69
+ v-for="option in options"
70
+ :key="String(option.value)"
71
+ type="button"
72
+ class="fg-select-option"
73
+ :disabled="option.disabled"
74
+ @click="select(option)"
75
+ >
76
+ <component :is="option.label" v-if="typeof option.label !== 'string'" />
77
+ <span v-else>{{ option.label }}</span>
78
+ </button>
79
+ </div>
80
+ </div>
81
+ </template>
@@ -0,0 +1,37 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import type { VNode } from 'vue';
8
+
9
+ import { IconClose } from './icons';
10
+
11
+ defineProps<{
12
+ closable?: boolean;
13
+ color?: 'amber' | 'white' | 'default';
14
+ prefixIcon?: VNode | string;
15
+ }>();
16
+
17
+ const emit = defineEmits<{
18
+ close: [];
19
+ }>();
20
+ </script>
21
+
22
+ <template>
23
+ <span class="fg-tag" :class="color || 'default'">
24
+ <img
25
+ v-if="typeof prefixIcon === 'string'"
26
+ :src="prefixIcon"
27
+ width="12"
28
+ height="12"
29
+ alt=""
30
+ />
31
+ <component :is="prefixIcon" v-else-if="prefixIcon" />
32
+ <slot />
33
+ <button v-if="closable" type="button" class="fg-tag-close" @click.stop="emit('close')">
34
+ <IconClose />
35
+ </button>
36
+ </span>
37
+ </template>
@@ -0,0 +1,42 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { computed } from 'vue';
8
+
9
+ const props = defineProps<{
10
+ modelValue?: string | number;
11
+ value?: string | number;
12
+ disabled?: boolean;
13
+ placeholder?: string;
14
+ rows?: number;
15
+ }>();
16
+
17
+ const emit = defineEmits<{
18
+ 'update:modelValue': [value: string];
19
+ change: [value: string];
20
+ }>();
21
+
22
+ const innerValue = computed(() =>
23
+ props.modelValue !== undefined ? props.modelValue : props.value
24
+ );
25
+
26
+ const onInput = (event: Event) => {
27
+ const next = (event.target as HTMLTextAreaElement).value;
28
+ emit('update:modelValue', next);
29
+ emit('change', next);
30
+ };
31
+ </script>
32
+
33
+ <template>
34
+ <textarea
35
+ class="fg-textarea"
36
+ :value="innerValue"
37
+ :disabled="disabled"
38
+ :placeholder="placeholder"
39
+ :rows="rows || 2"
40
+ @input="onInput"
41
+ />
42
+ </template>
@@ -0,0 +1,48 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { h, type VNode } from 'vue';
8
+
9
+ import type { FgTreeNode } from './types';
10
+
11
+ defineProps<{
12
+ nodes?: FgTreeNode[];
13
+ }>();
14
+
15
+ const emit = defineEmits<{
16
+ pick: [node: FgTreeNode];
17
+ }>();
18
+
19
+ const renderIcon = (icon?: VNode | string) => {
20
+ if (!icon) {
21
+ return null;
22
+ }
23
+ if (typeof icon === 'string') {
24
+ return h('img', { src: icon, width: 12, height: 12, alt: '', style: 'margin-right: 4px' });
25
+ }
26
+ return icon;
27
+ };
28
+ </script>
29
+
30
+ <template>
31
+ <div>
32
+ <div v-for="node in nodes || []" :key="node.key">
33
+ <button
34
+ type="button"
35
+ class="fg-tree-node"
36
+ :class="{ disabled: node.disabled }"
37
+ :disabled="node.disabled"
38
+ @click="emit('pick', node)"
39
+ >
40
+ <component :is="() => renderIcon(node.icon)" />
41
+ <span>{{ node.label }}</span>
42
+ </button>
43
+ <div v-if="node.children?.length" class="fg-tree-children">
44
+ <FgTreeNodes :nodes="node.children" @pick="emit('pick', $event)" />
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </template>
@@ -0,0 +1,86 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ import { computed, onBeforeUnmount, onMounted, ref, type VNode } from 'vue';
8
+
9
+ import FgTreeNodes from './fg-tree-nodes.vue';
10
+ import type { FgTreeNode } from './types';
11
+ import { IconChevronDown } from './icons';
12
+
13
+ const props = withDefaults(
14
+ defineProps<{
15
+ treeData?: FgTreeNode[];
16
+ value?: string;
17
+ disabled?: boolean;
18
+ placeholder?: string;
19
+ error?: boolean;
20
+ triggerRender?: () => VNode;
21
+ }>(),
22
+ { treeData: () => [] }
23
+ );
24
+
25
+ const emit = defineEmits<{
26
+ change: [value: string[] | undefined, node?: FgTreeNode];
27
+ }>();
28
+
29
+ const open = ref(false);
30
+ const rootRef = ref<HTMLElement | null>(null);
31
+
32
+ const findNode = (nodes: FgTreeNode[], key: string | undefined): FgTreeNode | undefined => {
33
+ if (!key) {
34
+ return undefined;
35
+ }
36
+ for (const node of nodes) {
37
+ if (node.key === key || node.value === key) {
38
+ return node;
39
+ }
40
+ const child = findNode(node.children || [], key);
41
+ if (child) {
42
+ return child;
43
+ }
44
+ }
45
+ return undefined;
46
+ };
47
+
48
+ const selected = computed(() => findNode(props.treeData, props.value));
49
+
50
+ const onDocClick = (event: MouseEvent) => {
51
+ if (rootRef.value && !rootRef.value.contains(event.target as Node)) {
52
+ open.value = false;
53
+ }
54
+ };
55
+
56
+ onMounted(() => document.addEventListener('mousedown', onDocClick));
57
+ onBeforeUnmount(() => document.removeEventListener('mousedown', onDocClick));
58
+
59
+ const pick = (node: FgTreeNode) => {
60
+ if (node.disabled) {
61
+ return;
62
+ }
63
+ emit('change', node.keyPath || node.key.split('.'), node);
64
+ open.value = false;
65
+ };
66
+ </script>
67
+
68
+ <template>
69
+ <div ref="rootRef" class="fg-tree-select" :class="{ error }">
70
+ <div
71
+ class="fg-tree-select-trigger"
72
+ :class="{ disabled }"
73
+ @click="!disabled && (open = !open)"
74
+ >
75
+ <slot name="selected" :option="selected">
76
+ <component :is="triggerRender" v-if="triggerRender" />
77
+ <span v-else-if="selected" class="fg-tree-select-value">{{ selected.label }}</span>
78
+ <span v-else class="fg-tree-select-placeholder">{{ placeholder }}</span>
79
+ </slot>
80
+ <IconChevronDown />
81
+ </div>
82
+ <div v-if="open" class="fg-tree-select-dropdown">
83
+ <FgTreeNodes :nodes="treeData" @pick="pick" />
84
+ </div>
85
+ </div>
86
+ </template>
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { h, type VNode } from 'vue';
7
+
8
+ function svg(pathD: string, viewBox = '0 0 16 16'): VNode {
9
+ return h(
10
+ 'svg',
11
+ {
12
+ class: 'fg-icon',
13
+ width: '14',
14
+ height: '14',
15
+ viewBox,
16
+ fill: 'none',
17
+ xmlns: 'http://www.w3.org/2000/svg',
18
+ 'aria-hidden': 'true',
19
+ },
20
+ h('path', { d: pathD, fill: 'currentColor' })
21
+ );
22
+ }
23
+
24
+ export const IconPlus = () =>
25
+ svg('M8 2.5a.75.75 0 0 1 .75.75V7.25h4a.75.75 0 0 1 0 1.5h-4v4a.75.75 0 0 1-1.5 0v-4h-4a.75.75 0 0 1 0-1.5h4V3.25A.75.75 0 0 1 8 2.5Z');
26
+
27
+ export const IconMinus = () => svg('M3 8a.75.75 0 0 1 .75-.75h8.5a.75.75 0 0 1 0 1.5h-8.5A.75.75 0 0 1 3 8Z');
28
+
29
+ export const IconDelete = () =>
30
+ svg(
31
+ 'M5.5 2.75A.75.75 0 0 1 6.25 2h3.5a.75.75 0 0 1 0 1.5h-3.5A.75.75 0 0 1 5.5 2.75ZM3 4.75A.75.75 0 0 1 3.75 4h8.5a.75.75 0 0 1 0 1.5H11.2l-.42 6.3A1.75 1.75 0 0 1 9.04 13.5H6.96a1.75 1.75 0 0 1-1.74-1.7L4.8 5.5H3.75A.75.75 0 0 1 3 4.75Z'
32
+ );
33
+
34
+ export const IconChevronDown = () => svg('M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z');
35
+
36
+ export const IconChevronRight = () => svg('M6.22 4.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06L7.28 11.78a.75.75 0 1 1-1.06-1.06L8.94 8 6.22 5.28a.75.75 0 0 1 0-1.06Z');
37
+
38
+ export const IconChevronDownStroked = IconChevronDown;
39
+
40
+ export const IconIssueStroked = () =>
41
+ svg(
42
+ 'M8 1.5A6.5 6.5 0 1 1 1.5 8 6.51 6.51 0 0 1 8 1.5ZM8 10a.9.9 0 1 0 0 1.8A.9.9 0 0 0 8 10Zm.75-5.25a.75.75 0 0 0-1.5 0v3.5a.75.75 0 0 0 1.5 0v-3.5Z'
43
+ );
44
+
45
+ export const IconSetting = () =>
46
+ svg(
47
+ 'M8 5.25A2.75 2.75 0 1 0 8 10.75 2.75 2.75 0 0 0 8 5.25ZM3.2 6.1 1.7 6.6a.75.75 0 0 0-.5.9l.5 1.9c.1.35.42.6.78.6l1.6.1c.2.4.45.77.75 1.1l-.4 1.55a.75.75 0 0 0 .4.85l1.8.95c.32.17.72.08.95-.2l1.05-1.25c.42.07.85.07 1.27 0l1.05 1.25c.23.28.63.37.95.2l1.8-.95a.75.75 0 0 0 .4-.85l-.4-1.55c.3-.33.55-.7.75-1.1l1.6-.1a.75.75 0 0 0 .78-.6l.5-1.9a.75.75 0 0 0-.5-.9l-1.5-.5c-.05-.43-.16-.85-.32-1.24l.85-1.4a.75.75 0 0 0-.15-.95L12.7 2.4a.75.75 0 0 0-.95-.1l-1.4.7c-.38-.2-.8-.35-1.23-.45L9 1.05A.75.75 0 0 0 8.25.4h-1.5A.75.75 0 0 0 6 1.05L5.88 2.55c-.43.1-.85.25-1.23.45l-1.4-.7a.75.75 0 0 0-.95.1L1.15 3.5a.75.75 0 0 0-.15.95l.85 1.4c-.16.39-.27.81-.32 1.24Z'
48
+ );
49
+
50
+ export const IconExpand = () =>
51
+ svg('M3 3.75A.75.75 0 0 1 3.75 3h3.5a.75.75 0 0 1 0 1.5H5.56l2.72 2.72a.75.75 0 1 1-1.06 1.06L4.5 5.56v1.69a.75.75 0 0 1-1.5 0v-3.5ZM13 12.25a.75.75 0 0 1-.75.75h-3.5a.75.75 0 0 1 0-1.5h1.69L7.72 8.78a.75.75 0 0 1 1.06-1.06L11.5 10.44V8.75a.75.75 0 0 1 1.5 0v3.5Z');
52
+
53
+ export const IconShrink = () =>
54
+ svg('M7.25 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-.75.75h-3.5a.75.75 0 0 1 0-1.5h1.69L2.78 4.22a.75.75 0 0 1 1.06-1.06L6.5 5.56V3.75A.75.75 0 0 1 7.25 3Zm1.5 10a.75.75 0 0 1-.75-.75v-3.5a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-1.69l2.72 2.72a.75.75 0 1 1-1.06 1.06L9.5 10.44v1.81a.75.75 0 0 1-.75.75Z');
55
+
56
+ export const IconAddChildren = () =>
57
+ svg('M4 2.75A.75.75 0 0 1 4.75 2h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 4 2.75ZM4 8a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5A.75.75 0 0 1 4 8Zm6.25-.75a.75.75 0 0 0 0 1.5h.5V9.5a.75.75 0 0 0 1.5 0v-.75h.5a.75.75 0 0 0 0-1.5h-.5V6.5a.75.75 0 0 0-1.5 0v.75h-.5ZM4.75 12.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z');
58
+
59
+ export const IconClose = () =>
60
+ svg('M4.22 4.22a.75.75 0 0 1 1.06 0L8 6.94l2.72-2.72a.75.75 0 1 1 1.06 1.06L9.06 8l2.72 2.72a.75.75 0 1 1-1.06 1.06L8 9.06l-2.72 2.72a.75.75 0 0 1-1.06-1.06L6.94 8 4.22 5.28a.75.75 0 0 1 0-1.06Z');