inicontent 1.0.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.
- package/.github/pull_request.yml +18 -0
- package/CONTRIBUTING.md +67 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/app/app.vue +106 -0
- package/app/assets/main.css +974 -0
- package/app/components/Api/EndpointCard.vue +169 -0
- package/app/components/Api/SchemaDocsTable.vue +208 -0
- package/app/components/Asset/Card.vue +1363 -0
- package/app/components/Asset/Grid.vue +295 -0
- package/app/components/Asset/Icon.vue +38 -0
- package/app/components/Asset/Preview.vue +486 -0
- package/app/components/Asset/Scanner.vue +700 -0
- package/app/components/Asset/Thumb.vue +708 -0
- package/app/components/Auth/Reset.vue +99 -0
- package/app/components/Auth/index.vue +346 -0
- package/app/components/ChatInterface.vue +2326 -0
- package/app/components/ChatPagePreview.vue +34 -0
- package/app/components/Column/Array.vue +29 -0
- package/app/components/Column/Asset.vue +21 -0
- package/app/components/Column/Boolean.vue +12 -0
- package/app/components/Column/Color.vue +9 -0
- package/app/components/Column/Date.vue +57 -0
- package/app/components/Column/Edit.vue +215 -0
- package/app/components/Column/Email.vue +9 -0
- package/app/components/Column/Html.vue +27 -0
- package/app/components/Column/Id.vue +20 -0
- package/app/components/Column/Locale.vue +32 -0
- package/app/components/Column/Object.vue +18 -0
- package/app/components/Column/Password.vue +7 -0
- package/app/components/Column/Role.vue +15 -0
- package/app/components/Column/S.vue +14 -0
- package/app/components/Column/Table/Single.vue +49 -0
- package/app/components/Column/Table/index.vue +42 -0
- package/app/components/Column/Tags.vue +31 -0
- package/app/components/Column/Text.vue +9 -0
- package/app/components/Column/Url.vue +9 -0
- package/app/components/Column/index.vue +41 -0
- package/app/components/Dashboard/Editor.vue +221 -0
- package/app/components/Dashboard/Grid.vue +270 -0
- package/app/components/Dashboard/View.vue +131 -0
- package/app/components/Dashboard/Widget/BarChart.vue +73 -0
- package/app/components/Dashboard/Widget/Counter.vue +51 -0
- package/app/components/Dashboard/Widget/LineChart.vue +76 -0
- package/app/components/Dashboard/Widget/PieChart.vue +75 -0
- package/app/components/Dashboard/Widget/Table.vue +94 -0
- package/app/components/Dashboard/WidgetEditor.vue +274 -0
- package/app/components/Data/Array.vue +102 -0
- package/app/components/Data/Html.vue +9 -0
- package/app/components/Data/Icon.vue +9 -0
- package/app/components/Data/Object.vue +10 -0
- package/app/components/Data/S.vue +16 -0
- package/app/components/Data/Table.vue +53 -0
- package/app/components/Data/Value.vue +34 -0
- package/app/components/Data/index.vue +14 -0
- package/app/components/Field/Array.vue +324 -0
- package/app/components/Field/Asset/Actions.vue +97 -0
- package/app/components/Field/Asset/index.vue +639 -0
- package/app/components/Field/Boolean.vue +26 -0
- package/app/components/Field/Checkbox.vue +48 -0
- package/app/components/Field/Color.vue +27 -0
- package/app/components/Field/Date.vue +30 -0
- package/app/components/Field/Email.vue +51 -0
- package/app/components/Field/EmailTemplate.vue +420 -0
- package/app/components/Field/Html/ColorPicker.vue +127 -0
- package/app/components/Field/Html/Editor.vue +544 -0
- package/app/components/Field/Html/index.vue +25 -0
- package/app/components/Field/Icon.vue +114 -0
- package/app/components/Field/JSON.vue +113 -0
- package/app/components/Field/Mention.vue +36 -0
- package/app/components/Field/Number.vue +27 -0
- package/app/components/Field/Object.vue +92 -0
- package/app/components/Field/Password.vue +55 -0
- package/app/components/Field/Radio.vue +47 -0
- package/app/components/Field/S.vue +44 -0
- package/app/components/Field/Select.vue +49 -0
- package/app/components/Field/Table.vue +348 -0
- package/app/components/Field/Tags.vue +113 -0
- package/app/components/Field/Text.vue +31 -0
- package/app/components/Field/Textarea.vue +33 -0
- package/app/components/Field/Url.vue +40 -0
- package/app/components/Field/Wrapper.vue +128 -0
- package/app/components/Field/index.vue +68 -0
- package/app/components/FloatingChatbot.vue +73 -0
- package/app/components/Form/Card.vue +151 -0
- package/app/components/Form/Drawer.vue +195 -0
- package/app/components/Form/index.vue +621 -0
- package/app/components/Header.vue +328 -0
- package/app/components/Offline/ConflictModal.vue +200 -0
- package/app/components/Offline/SyncStatus.vue +249 -0
- package/app/components/PlatformFeatureLanding.vue +65 -0
- package/app/components/Table/Backups.vue +638 -0
- package/app/components/Table/Flows.vue +814 -0
- package/app/components/Table/Grid.vue +296 -0
- package/app/components/Table/Icon.vue +36 -0
- package/app/components/Table/Logs.vue +181 -0
- package/app/components/Table/Schedules.vue +722 -0
- package/app/components/Table/Search/Button.vue +256 -0
- package/app/components/Table/Search/Items.vue +286 -0
- package/app/components/Table/Search/index.vue +87 -0
- package/app/components/Table/Settings/Schema.vue +801 -0
- package/app/components/Table/Settings/index.vue +631 -0
- package/app/components/Table/TranslateDrawer.vue +526 -0
- package/app/components/Table/Views/Kanban.vue +289 -0
- package/app/components/Table/Views/Table.vue +1273 -0
- package/app/components/Table/index.vue +890 -0
- package/app/composables/Translation/define.ts +41 -0
- package/app/composables/Translation/fetch.ts +107 -0
- package/app/composables/Translation/languages.ts +1 -0
- package/app/composables/Translation/loadCoreTranslations.ts +38 -0
- package/app/composables/Translation/translate.ts +250 -0
- package/app/composables/databaseCookies.ts +79 -0
- package/app/composables/fieldValidator.ts +72 -0
- package/app/composables/fieldsList.ts +301 -0
- package/app/composables/formatDatabase.ts +101 -0
- package/app/composables/index.ts +444 -0
- package/app/composables/openDrawer.ts +118 -0
- package/app/composables/optimizeFile.ts +287 -0
- package/app/composables/renderLabel.ts +88 -0
- package/app/composables/schemaClipboard.ts +95 -0
- package/app/composables/search.ts +353 -0
- package/app/composables/setThemeConfig.ts +48 -0
- package/app/composables/translationValue.ts +169 -0
- package/app/composables/useAssetPreview.ts +84 -0
- package/app/composables/useAssetUploader.ts +56 -0
- package/app/composables/useDashboardData.ts +310 -0
- package/app/composables/useDocumentThumbnail.ts +351 -0
- package/app/composables/useEcharts.ts +33 -0
- package/app/composables/useLocalDatabaseConfig.ts +51 -0
- package/app/composables/useOcr.ts +300 -0
- package/app/composables/useOfflineFetch.ts +194 -0
- package/app/composables/useOfflineItem.ts +107 -0
- package/app/composables/useOfflineQueue.ts +302 -0
- package/app/composables/useOfflineSync.ts +235 -0
- package/app/composables/usePasskeyAuth.ts +156 -0
- package/app/composables/usePdfCompressor.ts +180 -0
- package/app/composables/usePlatformRedirect.ts +72 -0
- package/app/composables/useRealtimeSync.ts +233 -0
- package/app/composables/useReferencedItems.ts +180 -0
- package/app/composables/useScanner.ts +664 -0
- package/app/composables/useSubscription.ts +650 -0
- package/app/composables/useThumbnailCache.ts +136 -0
- package/app/composables/useVideoCompressor.ts +194 -0
- package/app/error.vue +112 -0
- package/app/layouts/api.vue +188 -0
- package/app/layouts/dashboard.vue +91 -0
- package/app/layouts/default.vue +228 -0
- package/app/layouts/table.vue +471 -0
- package/app/locales/ar.ts +996 -0
- package/app/locales/en.ts +655 -0
- package/app/locales/es.ts +996 -0
- package/app/locales/fr.ts +997 -0
- package/app/middleware/dashboard.ts +33 -0
- package/app/middleware/database.ts +83 -0
- package/app/middleware/global.ts +1 -0
- package/app/middleware/sid-ingest.global.ts +29 -0
- package/app/middleware/table.ts +54 -0
- package/app/middleware/user.ts +26 -0
- package/app/pages/[[database]]/admin/api/auth/index.vue +306 -0
- package/app/pages/[[database]]/admin/api/index.vue +18 -0
- package/app/pages/[[database]]/admin/api/tables/[table]/index.vue +497 -0
- package/app/pages/[[database]]/admin/api/tables/index.vue +87 -0
- package/app/pages/[[database]]/admin/billing/index.vue +16 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/edit.vue +66 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/index.vue +117 -0
- package/app/pages/[[database]]/admin/dashboards/index.vue +20 -0
- package/app/pages/[[database]]/admin/index.vue +28 -0
- package/app/pages/[[database]]/admin/settings.vue +526 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/edit.vue +143 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/index.vue +146 -0
- package/app/pages/[[database]]/admin/tables/[table]/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/new.vue +12 -0
- package/app/pages/[[database]]/admin/tables/[table]/schedules.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/settings.vue +30 -0
- package/app/pages/[[database]]/admin/tables/assets/[...path].vue +24 -0
- package/app/pages/[[database]]/admin/tables/assets/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/backups/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/blocks/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/index.vue +20 -0
- package/app/pages/[[database]]/admin/tables/pages/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/templates/index.vue +16 -0
- package/app/pages/[[database]]/api/index.vue +120 -0
- package/app/pages/[[database]]/auth/index.vue +12 -0
- package/app/pages/[[database]]/auth/reset.vue +10 -0
- package/app/pages/[[database]]/index.vue +10 -0
- package/app/plugins/offline-warmup.client.ts +53 -0
- package/app/plugins/template-globals.ts +9 -0
- package/app/spa-loading-template.html +93 -0
- package/biome.json +53 -0
- package/index.d.ts +380 -0
- package/modules/naiveui.ts +41 -0
- package/nuxt.config.ts +269 -0
- package/package.json +56 -0
- package/pnpm-workspace.yaml +5 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/pwa-192x192.png +0 -0
- package/public/pwa-512x512.png +0 -0
- package/public/pwa-maskable-192x192.png +0 -0
- package/public/pwa-maskable-512x512.png +0 -0
- package/public/vendor/opencv.js +48 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper :field :rule v-model="internalValue">
|
|
3
|
+
<NInput v-model:value="internalValue" :placeholder="t(field.key)" clearable type="textarea"
|
|
4
|
+
:rows="field.isTable ? 1 : undefined" :autosize="field.isTable ? false : {
|
|
5
|
+
minRows: 5,
|
|
6
|
+
maxRows: 20,
|
|
7
|
+
}" :status="hasError ? 'error' : undefined" v-bind="field.inputProps
|
|
8
|
+
? typeof field.inputProps === 'function'
|
|
9
|
+
? field.inputProps(internalValue) ?? {}
|
|
10
|
+
: field.inputProps
|
|
11
|
+
: {}">
|
|
12
|
+
<template #suffix>
|
|
13
|
+
<component :is="getField(field).icon" />
|
|
14
|
+
</template>
|
|
15
|
+
</NInput>
|
|
16
|
+
<div v-if="hasError" style="color: var(--error-color); font-size: 12px; margin-top: 4px;">
|
|
17
|
+
{{ t("invalidJSON") }}
|
|
18
|
+
</div>
|
|
19
|
+
<template v-if="!field.isTable && internalValue" #footer>
|
|
20
|
+
<NFlex justify="space-between" align="center">
|
|
21
|
+
<span style="font-size: 12px; color: var(--text-color-3);">
|
|
22
|
+
{{ formattedSize }}
|
|
23
|
+
</span>
|
|
24
|
+
<NFlex gap="small">
|
|
25
|
+
<NButton text type="primary" size="small" @click="formatJSON" :disabled="hasError">
|
|
26
|
+
{{ t("format") }}
|
|
27
|
+
</NButton>
|
|
28
|
+
</NFlex>
|
|
29
|
+
</NFlex>
|
|
30
|
+
</template>
|
|
31
|
+
</FieldWrapper>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script lang="ts" setup>
|
|
35
|
+
import type { FormItemRule } from "naive-ui";
|
|
36
|
+
import { NButton, NFlex } from "#components";
|
|
37
|
+
|
|
38
|
+
const { field } = defineProps<{ field: Field }>();
|
|
39
|
+
|
|
40
|
+
const modelValue = defineModel<any>();
|
|
41
|
+
|
|
42
|
+
// Convert parsed object to JSON string for display
|
|
43
|
+
const stringifyValue = (value: any): string => {
|
|
44
|
+
if (!value) return "";
|
|
45
|
+
if (typeof value === "string") return value;
|
|
46
|
+
return JSON.stringify(value, null, 2);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const internalValue = ref<string>(stringifyValue(modelValue.value));
|
|
50
|
+
|
|
51
|
+
const hasError = computed(() => {
|
|
52
|
+
if (!internalValue.value) return false;
|
|
53
|
+
try {
|
|
54
|
+
JSON.parse(internalValue.value);
|
|
55
|
+
return false;
|
|
56
|
+
} catch {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const formattedSize = computed(() => {
|
|
62
|
+
if (!internalValue.value) return "0 B";
|
|
63
|
+
const bytes = new Blob([internalValue.value]).size;
|
|
64
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
65
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
|
|
66
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const rule: FormItemRule = {
|
|
70
|
+
trigger: ["blur", "input"],
|
|
71
|
+
required: field.required,
|
|
72
|
+
validator: async () => {
|
|
73
|
+
await nextTick();
|
|
74
|
+
if (field.required && !internalValue.value) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (internalValue.value && hasError.value) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return fieldValidator(field, internalValue.value);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const formatJSON = () => {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(internalValue.value);
|
|
87
|
+
internalValue.value = JSON.stringify(parsed, null, 2);
|
|
88
|
+
modelValue.value = parsed;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error("JSON formatting failed:", error);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
watch(internalValue, (newValue) => {
|
|
95
|
+
if (!newValue) {
|
|
96
|
+
modelValue.value = null;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(newValue);
|
|
101
|
+
modelValue.value = parsed;
|
|
102
|
+
} catch {
|
|
103
|
+
// Don't update modelValue if JSON is invalid - keep previous value
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
watch(modelValue, (newValue) => {
|
|
108
|
+
const stringified = stringifyValue(newValue);
|
|
109
|
+
if (stringified !== internalValue.value) {
|
|
110
|
+
internalValue.value = stringified;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
</script>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper :field :rule v-model="modelValue">
|
|
3
|
+
<NMention v-model:value="modelValue" :placeholder="t(field.key)" :options clearable v-bind="field.inputProps
|
|
4
|
+
? typeof field.inputProps === 'function'
|
|
5
|
+
? field.inputProps(modelValue) ?? {}
|
|
6
|
+
: field.inputProps
|
|
7
|
+
: {}">
|
|
8
|
+
</NMention>
|
|
9
|
+
</FieldWrapper>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { isArrayOfObjects } from "inibase/utils"
|
|
14
|
+
import type { FormItemRule } from "naive-ui"
|
|
15
|
+
|
|
16
|
+
const { field } = defineProps<{ field: Field }>()
|
|
17
|
+
|
|
18
|
+
const modelValue = defineModel<string>()
|
|
19
|
+
|
|
20
|
+
const rule: FormItemRule = {
|
|
21
|
+
required: field.required,
|
|
22
|
+
validator: async () => {
|
|
23
|
+
await nextTick()
|
|
24
|
+
return fieldValidator(field, modelValue.value)
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const options = field.options
|
|
29
|
+
? isArrayOfObjects(field.options)
|
|
30
|
+
? field.options
|
|
31
|
+
: (field.options as string[]).map((value) => ({
|
|
32
|
+
value: value,
|
|
33
|
+
label: t(value),
|
|
34
|
+
}))
|
|
35
|
+
: []
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper :field :rule v-model="modelValue">
|
|
3
|
+
<NInputNumber v-model:value="modelValue" :placeholder="t(field.key)" :show-button="false" clearable v-bind="field.inputProps
|
|
4
|
+
? typeof field.inputProps === 'function'
|
|
5
|
+
? field.inputProps(modelValue) ?? {}
|
|
6
|
+
: field.inputProps
|
|
7
|
+
: {}">
|
|
8
|
+
<template #suffix>
|
|
9
|
+
<component :is="getField(field).icon" />
|
|
10
|
+
</template>
|
|
11
|
+
</NInputNumber>
|
|
12
|
+
</FieldWrapper>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import type { FormItemRule } from "naive-ui";
|
|
17
|
+
const { field } = defineProps<{ field: Field }>();
|
|
18
|
+
const modelValue = defineModel<number>();
|
|
19
|
+
const rule: FormItemRule = {
|
|
20
|
+
trigger: ["blur", "input"],
|
|
21
|
+
required: field.required,
|
|
22
|
+
validator: async () => {
|
|
23
|
+
await nextTick();
|
|
24
|
+
return fieldValidator(field, modelValue.value);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NCollapse :default-expanded-names="field.expand ? String(field.id) : undefined" display-directive="show"
|
|
3
|
+
arrow-placement="right" :trigger-areas="['main', 'arrow']" accordion>
|
|
4
|
+
<NCollapseItem style="margin: 0 0 20px;" display-directive="show" :name="String(field.id)">
|
|
5
|
+
<template #header>
|
|
6
|
+
<NDropdown size="small" :placement="Language === 'ar' ? 'left' : 'right'" show-arrow trigger="hover"
|
|
7
|
+
:delay="1500" :options="dropdownOptions" @select="handleSelect">
|
|
8
|
+
{{ t(field.key) }}
|
|
9
|
+
</NDropdown>
|
|
10
|
+
</template>
|
|
11
|
+
<div class="collapseContentPadding">
|
|
12
|
+
<NFlex>
|
|
13
|
+
<LazyField v-for="childField of (field.children as Schema)" :field="childField"
|
|
14
|
+
v-model="localModelValue[childField.key]" />
|
|
15
|
+
</NFlex>
|
|
16
|
+
</div>
|
|
17
|
+
</NCollapseItem>
|
|
18
|
+
</NCollapse>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { isObject, isStringified } from "inibase/utils";
|
|
23
|
+
import Inison from "inison";
|
|
24
|
+
import type { DropdownOption } from "naive-ui";
|
|
25
|
+
import { Icon, NIcon } from "#components";
|
|
26
|
+
|
|
27
|
+
const database = useState<Database>("database");
|
|
28
|
+
const Language = useScopedCookie<LanguagesType>("language", database.value?.slug);
|
|
29
|
+
|
|
30
|
+
const { field } = defineProps<{ field: Field }>();
|
|
31
|
+
|
|
32
|
+
const modelValue = defineModel<Record<string | number, any>>();
|
|
33
|
+
|
|
34
|
+
const localModelValue = ref<Record<string | number, any>>(
|
|
35
|
+
toRaw(modelValue.value ?? {}),
|
|
36
|
+
);
|
|
37
|
+
watch(
|
|
38
|
+
localModelValue,
|
|
39
|
+
(v) => {
|
|
40
|
+
modelValue.value = v;
|
|
41
|
+
},
|
|
42
|
+
{ deep: true },
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
async function handleSelect(value: string) {
|
|
46
|
+
switch (value) {
|
|
47
|
+
case "copy": {
|
|
48
|
+
if (!modelValue.value) return;
|
|
49
|
+
await copyToClipboard(Inison.stringify(modelValue.value));
|
|
50
|
+
window.$message.success(t("copiedSuccessfully"));
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case "paste": {
|
|
54
|
+
try {
|
|
55
|
+
const itemFromClipboard = await navigator.clipboard.readText();
|
|
56
|
+
|
|
57
|
+
if (!itemFromClipboard) {
|
|
58
|
+
window.$message.error(t("clipboardEmpty"));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!isStringified(itemFromClipboard)) {
|
|
62
|
+
window.$message.error(t("clipboardItemIsNotCorrect"));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const unstringifiedItem = Inison.unstringify<Item[]>(itemFromClipboard);
|
|
67
|
+
if (!unstringifiedItem && !isObject(unstringifiedItem)) {
|
|
68
|
+
window.$message.error(t("clipboardItemIsNotCorrect"));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
modelValue.value = unstringifiedItem;
|
|
73
|
+
} catch {
|
|
74
|
+
window.$message.error(t("clipboardItemIsNotCorrect"));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const dropdownOptions = computed<DropdownOption[]>(() => [
|
|
80
|
+
{
|
|
81
|
+
label: t("copyItem"),
|
|
82
|
+
key: "copy",
|
|
83
|
+
show: !!modelValue.value,
|
|
84
|
+
icon: () => h(NIcon, () => h(Icon, { name: "tabler:copy" })),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: t("pasteItem"),
|
|
88
|
+
key: "paste",
|
|
89
|
+
icon: () => h(NIcon, () => h(Icon, { name: "tabler:clipboard" })),
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper :field :rule v-model="modelValue">
|
|
3
|
+
<NInput type="password" show-password-on="click" v-model:value="localModelValue" :placeholder="t(field.key)"
|
|
4
|
+
clearable v-bind="field.inputProps
|
|
5
|
+
? typeof field.inputProps === 'function'
|
|
6
|
+
? field.inputProps(modelValue) ?? {}
|
|
7
|
+
: field.inputProps
|
|
8
|
+
: {}">
|
|
9
|
+
<template #suffix>
|
|
10
|
+
<component :is="getField(field).icon" />
|
|
11
|
+
</template>
|
|
12
|
+
</NInput>
|
|
13
|
+
</FieldWrapper>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts" setup>
|
|
17
|
+
import type { FormItemRule } from "naive-ui"
|
|
18
|
+
|
|
19
|
+
const { field } = defineProps<{ field: Field }>()
|
|
20
|
+
const modelValue = defineModel<string>()
|
|
21
|
+
const localModelValue = ref<string | undefined>(
|
|
22
|
+
modelValue.value !== undefined && modelValue.value !== null
|
|
23
|
+
? String(modelValue.value)
|
|
24
|
+
: undefined,
|
|
25
|
+
)
|
|
26
|
+
watch(localModelValue, (v) => {
|
|
27
|
+
modelValue.value = v
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const rule: FormItemRule = {
|
|
31
|
+
trigger: ["blur", "input"],
|
|
32
|
+
required: field.required,
|
|
33
|
+
validator: async () => {
|
|
34
|
+
if (!alreadyRun.value) {
|
|
35
|
+
await nextTick()
|
|
36
|
+
return fieldValidator(field, localModelValue.value)
|
|
37
|
+
}
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
resolve()
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const alreadyRun = ref(false)
|
|
45
|
+
onMounted(() => {
|
|
46
|
+
if (
|
|
47
|
+
localModelValue.value !== undefined &&
|
|
48
|
+
localModelValue.value !== "" &&
|
|
49
|
+
localModelValue.value !== null
|
|
50
|
+
) {
|
|
51
|
+
alreadyRun.value = true
|
|
52
|
+
localModelValue.value = undefined
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper :field :rule v-model="modelValue">
|
|
3
|
+
<NRadioGroup v-model:value="modelValue" v-bind="field.inputProps
|
|
4
|
+
? typeof field.inputProps === 'function'
|
|
5
|
+
? field.inputProps(modelValue) ?? {}
|
|
6
|
+
: field.inputProps
|
|
7
|
+
: {}">
|
|
8
|
+
<NFlex>
|
|
9
|
+
<NRadio v-for="{ label, value } in options" :value :label />
|
|
10
|
+
</NFlex>
|
|
11
|
+
</NRadioGroup>
|
|
12
|
+
</FieldWrapper>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { isArrayOfArrays, isArrayOfObjects } from "inibase/utils"
|
|
17
|
+
import type { FormItemRule } from "naive-ui"
|
|
18
|
+
|
|
19
|
+
const { field } = defineProps<{ field: Field }>()
|
|
20
|
+
|
|
21
|
+
const modelValue = defineModel<string | number>()
|
|
22
|
+
|
|
23
|
+
const rule: FormItemRule = {
|
|
24
|
+
trigger: "change",
|
|
25
|
+
required: field.required,
|
|
26
|
+
validator: async () => {
|
|
27
|
+
await nextTick()
|
|
28
|
+
return fieldValidator(field, modelValue.value)
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const options = computed(() =>
|
|
33
|
+
field.options
|
|
34
|
+
? isArrayOfArrays(field.options)
|
|
35
|
+
? (field.options as [string | number, string][]).map(([value]) => ({
|
|
36
|
+
value: value,
|
|
37
|
+
label: t(value),
|
|
38
|
+
}))
|
|
39
|
+
: isArrayOfObjects(field.options)
|
|
40
|
+
? field.options
|
|
41
|
+
: (field.options as string[]).map((value) => ({
|
|
42
|
+
value: value,
|
|
43
|
+
label: t(value),
|
|
44
|
+
}))
|
|
45
|
+
: [],
|
|
46
|
+
)
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NFlex>
|
|
3
|
+
<Field
|
|
4
|
+
v-for="field of formatedSchema"
|
|
5
|
+
:field="field"
|
|
6
|
+
:item="modelValue"
|
|
7
|
+
v-model="modelValue[field.key]"
|
|
8
|
+
/>
|
|
9
|
+
</NFlex>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { isArrayOfObjects } from "inibase/utils";
|
|
14
|
+
|
|
15
|
+
function addIdToSchema(schema: Schema, startWithID = 0) {
|
|
16
|
+
function _addIdToField(field: Field) {
|
|
17
|
+
if (!field.id) {
|
|
18
|
+
startWithID++;
|
|
19
|
+
field.id = `temp-${startWithID}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
(field.type === "array" || field.type === "object") &&
|
|
24
|
+
isArrayOfObjects(field.children)
|
|
25
|
+
)
|
|
26
|
+
field.children = _addIdToSchema(field.children);
|
|
27
|
+
return field;
|
|
28
|
+
}
|
|
29
|
+
const _addIdToSchema = (schema: Schema) => schema.map(_addIdToField);
|
|
30
|
+
|
|
31
|
+
return _addIdToSchema(schema);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// TO-DO:
|
|
35
|
+
// Add fields: Mention, Range, Slider
|
|
36
|
+
const schema = defineModel<Schema>("schema");
|
|
37
|
+
const formatedSchema = computed(() =>
|
|
38
|
+
schema.value?.length ? addIdToSchema(toRaw(schema.value)) : [],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const modelValue = defineModel<Record<string | number, any>>({
|
|
42
|
+
default: () => reactive({}),
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper :field :rule v-model="modelValue">
|
|
3
|
+
<NSelect v-model:value="modelValue" :placeholder="t(field.key)" :options :tag="!!field.custom"
|
|
4
|
+
max-tag-count="responsive" :consistent-menu-width="false" :multiple="!!field.isArray" filterable clearable
|
|
5
|
+
v-bind="field.inputProps
|
|
6
|
+
? typeof field.inputProps === 'function'
|
|
7
|
+
? field.inputProps(modelValue) ?? {}
|
|
8
|
+
: field.inputProps
|
|
9
|
+
: {}" />
|
|
10
|
+
</FieldWrapper>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts" setup>
|
|
14
|
+
import { isArrayOfArrays, isArrayOfObjects } from "inibase/utils";
|
|
15
|
+
import type { FormItemRule } from "naive-ui";
|
|
16
|
+
|
|
17
|
+
const { field } = defineProps<{ field: Field }>();
|
|
18
|
+
|
|
19
|
+
const modelValue = defineModel<string | string[]>();
|
|
20
|
+
if (modelValue.value && isArrayOfArrays(modelValue.value))
|
|
21
|
+
modelValue.value = modelValue.value.flat();
|
|
22
|
+
|
|
23
|
+
const rule: FormItemRule = {
|
|
24
|
+
trigger: "change",
|
|
25
|
+
type: field.isArray ? "array" : "any",
|
|
26
|
+
required: field.required,
|
|
27
|
+
min: field.isArray ? field.min : undefined,
|
|
28
|
+
max: field.isArray ? field.max : undefined,
|
|
29
|
+
validator: async () => {
|
|
30
|
+
await nextTick();
|
|
31
|
+
return fieldValidator(field, modelValue.value);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const options = computed(() =>
|
|
35
|
+
field.options
|
|
36
|
+
? isArrayOfArrays(field.options)
|
|
37
|
+
? (field.options as [string | number, string][]).map(([value]) => ({
|
|
38
|
+
value: value,
|
|
39
|
+
label: t(value),
|
|
40
|
+
}))
|
|
41
|
+
: isArrayOfObjects(field.options)
|
|
42
|
+
? field.options
|
|
43
|
+
: (field.options as string[]).map((value) => ({
|
|
44
|
+
value: value,
|
|
45
|
+
label: t(value),
|
|
46
|
+
}))
|
|
47
|
+
: [],
|
|
48
|
+
);
|
|
49
|
+
</script>
|