@kissflow/create-app 0.1.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/LICENSE +21 -0
- package/README.md +9 -0
- package/bin/index.js +80 -0
- package/package.json +47 -0
- package/scaffolders/app/index.js +49 -0
- package/scaffolders/app/template/_CLAUDE.md +104 -0
- package/scaffolders/app/template/_README.md +54 -0
- package/scaffolders/app/template/_env.example +10 -0
- package/scaffolders/app/template/_gitignore +6 -0
- package/scaffolders/app/template/_package.json +55 -0
- package/scaffolders/app/template/_prettierrc +6 -0
- package/scaffolders/app/template/agents/design-guidelines.md +172 -0
- package/scaffolders/app/template/agents/kissflow-sdk.md +257 -0
- package/scaffolders/app/template/agents/theming.md +61 -0
- package/scaffolders/app/template/cert/localhost.crt +18 -0
- package/scaffolders/app/template/cert/localhost.key +28 -0
- package/scaffolders/app/template/components.json +21 -0
- package/scaffolders/app/template/index.html +12 -0
- package/scaffolders/app/template/jsconfig.json +8 -0
- package/scaffolders/app/template/lib/kf-schema.json +7 -0
- package/scaffolders/app/template/scripts/zip.js +54 -0
- package/scaffolders/app/template/src/components/app-shell.jsx +208 -0
- package/scaffolders/app/template/src/components/fields/AggregationField.jsx +42 -0
- package/scaffolders/app/template/src/components/fields/AttachmentField.jsx +175 -0
- package/scaffolders/app/template/src/components/fields/BooleanField.jsx +47 -0
- package/scaffolders/app/template/src/components/fields/CheckboxField.jsx +79 -0
- package/scaffolders/app/template/src/components/fields/ChecklistField.jsx +190 -0
- package/scaffolders/app/template/src/components/fields/CurrencyField.jsx +183 -0
- package/scaffolders/app/template/src/components/fields/DateField.jsx +65 -0
- package/scaffolders/app/template/src/components/fields/DateTimeField.jsx +186 -0
- package/scaffolders/app/template/src/components/fields/EmailField.jsx +30 -0
- package/scaffolders/app/template/src/components/fields/FieldError.jsx +11 -0
- package/scaffolders/app/template/src/components/fields/FieldLabel.jsx +14 -0
- package/scaffolders/app/template/src/components/fields/GeolocationField.jsx +99 -0
- package/scaffolders/app/template/src/components/fields/ImageField.jsx +149 -0
- package/scaffolders/app/template/src/components/fields/LookupField.jsx +256 -0
- package/scaffolders/app/template/src/components/fields/MultiSelectField.jsx +152 -0
- package/scaffolders/app/template/src/components/fields/MultiUserSelectField.jsx +153 -0
- package/scaffolders/app/template/src/components/fields/NumberField.jsx +30 -0
- package/scaffolders/app/template/src/components/fields/RadioField.jsx +78 -0
- package/scaffolders/app/template/src/components/fields/RatingField.jsx +64 -0
- package/scaffolders/app/template/src/components/fields/ScannerField.jsx +62 -0
- package/scaffolders/app/template/src/components/fields/SelectField.jsx +74 -0
- package/scaffolders/app/template/src/components/fields/SequenceNumberField.jsx +22 -0
- package/scaffolders/app/template/src/components/fields/SignatureField.jsx +344 -0
- package/scaffolders/app/template/src/components/fields/SliderField.jsx +39 -0
- package/scaffolders/app/template/src/components/fields/SmartAttachmentField.jsx +188 -0
- package/scaffolders/app/template/src/components/fields/TextField.jsx +30 -0
- package/scaffolders/app/template/src/components/fields/TextareaField.jsx +30 -0
- package/scaffolders/app/template/src/components/fields/UserSelectField.jsx +76 -0
- package/scaffolders/app/template/src/components/fields/index.js +87 -0
- package/scaffolders/app/template/src/components/fields/useGeolocationPicker.js +42 -0
- package/scaffolders/app/template/src/components/fields/useScanner.js +43 -0
- package/scaffolders/app/template/src/components/form/FormAction.jsx +86 -0
- package/scaffolders/app/template/src/components/form/FormBody.jsx +163 -0
- package/scaffolders/app/template/src/components/form/FormHeader.jsx +65 -0
- package/scaffolders/app/template/src/components/form/ProcessActions.jsx +270 -0
- package/scaffolders/app/template/src/components/form/index.jsx +119 -0
- package/scaffolders/app/template/src/components/form/shared.jsx +213 -0
- package/scaffolders/app/template/src/components/tablefields/TableAggregationField.jsx +14 -0
- package/scaffolders/app/template/src/components/tablefields/TableAttachmentField.jsx +53 -0
- package/scaffolders/app/template/src/components/tablefields/TableBooleanField.jsx +26 -0
- package/scaffolders/app/template/src/components/tablefields/TableCheckboxField.jsx +6 -0
- package/scaffolders/app/template/src/components/tablefields/TableChecklistField.jsx +48 -0
- package/scaffolders/app/template/src/components/tablefields/TableCurrencyField.jsx +140 -0
- package/scaffolders/app/template/src/components/tablefields/TableDateField.jsx +49 -0
- package/scaffolders/app/template/src/components/tablefields/TableDateTimeField.jsx +170 -0
- package/scaffolders/app/template/src/components/tablefields/TableGeolocationField.jsx +69 -0
- package/scaffolders/app/template/src/components/tablefields/TableImageField.jsx +78 -0
- package/scaffolders/app/template/src/components/tablefields/TableLookupField.jsx +165 -0
- package/scaffolders/app/template/src/components/tablefields/TableMultiSelectField.jsx +111 -0
- package/scaffolders/app/template/src/components/tablefields/TableMultiUserSelectField.jsx +109 -0
- package/scaffolders/app/template/src/components/tablefields/TableNumberField.jsx +33 -0
- package/scaffolders/app/template/src/components/tablefields/TableRatingField.jsx +45 -0
- package/scaffolders/app/template/src/components/tablefields/TableScannerField.jsx +67 -0
- package/scaffolders/app/template/src/components/tablefields/TableSelectField.jsx +47 -0
- package/scaffolders/app/template/src/components/tablefields/TableSequenceNumberField.jsx +7 -0
- package/scaffolders/app/template/src/components/tablefields/TableSignatureField.jsx +59 -0
- package/scaffolders/app/template/src/components/tablefields/TableSliderField.jsx +26 -0
- package/scaffolders/app/template/src/components/tablefields/TableTextField.jsx +28 -0
- package/scaffolders/app/template/src/components/tablefields/TableUserSelectField.jsx +51 -0
- package/scaffolders/app/template/src/components/tablefields/index.js +71 -0
- package/scaffolders/app/template/src/components/tablefields/useTableFieldOptions.js +33 -0
- package/scaffolders/app/template/src/components/ui/accordion.jsx +51 -0
- package/scaffolders/app/template/src/components/ui/avatar.jsx +92 -0
- package/scaffolders/app/template/src/components/ui/badge.jsx +40 -0
- package/scaffolders/app/template/src/components/ui/button.jsx +61 -0
- package/scaffolders/app/template/src/components/ui/calendar.jsx +207 -0
- package/scaffolders/app/template/src/components/ui/card.jsx +92 -0
- package/scaffolders/app/template/src/components/ui/chart.jsx +323 -0
- package/scaffolders/app/template/src/components/ui/checkbox.jsx +27 -0
- package/scaffolders/app/template/src/components/ui/command.jsx +154 -0
- package/scaffolders/app/template/src/components/ui/dialog.jsx +122 -0
- package/scaffolders/app/template/src/components/ui/dropdown-menu.jsx +200 -0
- package/scaffolders/app/template/src/components/ui/input.jsx +21 -0
- package/scaffolders/app/template/src/components/ui/label.jsx +19 -0
- package/scaffolders/app/template/src/components/ui/popover.jsx +40 -0
- package/scaffolders/app/template/src/components/ui/progress.jsx +25 -0
- package/scaffolders/app/template/src/components/ui/radio-group.jsx +37 -0
- package/scaffolders/app/template/src/components/ui/scroll-area.jsx +48 -0
- package/scaffolders/app/template/src/components/ui/select.jsx +156 -0
- package/scaffolders/app/template/src/components/ui/separator.jsx +26 -0
- package/scaffolders/app/template/src/components/ui/sheet.jsx +123 -0
- package/scaffolders/app/template/src/components/ui/skeleton.jsx +13 -0
- package/scaffolders/app/template/src/components/ui/slider.jsx +61 -0
- package/scaffolders/app/template/src/components/ui/sonner.jsx +60 -0
- package/scaffolders/app/template/src/components/ui/switch.jsx +26 -0
- package/scaffolders/app/template/src/components/ui/table.jsx +111 -0
- package/scaffolders/app/template/src/components/ui/tabs.jsx +74 -0
- package/scaffolders/app/template/src/components/ui/textarea.jsx +18 -0
- package/scaffolders/app/template/src/components/ui/tooltip.jsx +43 -0
- package/scaffolders/app/template/src/hooks/useForm.js +841 -0
- package/scaffolders/app/template/src/index.css +143 -0
- package/scaffolders/app/template/src/lib/utils.js +6 -0
- package/scaffolders/app/template/src/main.jsx +18 -0
- package/scaffolders/app/template/src/pages/index.jsx +244 -0
- package/scaffolders/app/template/src/themes.css +153 -0
- package/scaffolders/app/template/src/themes.js +32 -0
- package/scaffolders/app/template/vite-kf-live.js +117 -0
- package/scaffolders/app/template/vite.config.js +56 -0
- package/scaffolders/constants.js +25 -0
- package/scaffolders/helpers.js +12 -0
- package/scaffolders/utils.js +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 KiSSFLOW
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# create-app
|
|
2
|
+
|
|
3
|
+
`create-app` is a cli tool that lets developers scaffold a Kissflow custom app project - a minimal frontend project that seamlessly integrates with Kissflow's products and extends its functionality.
|
|
4
|
+
|
|
5
|
+
## To scaffold a custom app project,
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm create kf-app
|
|
9
|
+
```
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
|
|
8
|
+
import { appScaffolder } from "../scaffolders/app/index.js";
|
|
9
|
+
import { isValidPackageName, makeDirectory } from "../scaffolders/utils.js";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
|
|
12
|
+
// Non-interactive flags (so AI agents / CI can scaffold in one command):
|
|
13
|
+
// create-app --name my-app --yes
|
|
14
|
+
// Any value not supplied as a flag falls back to an interactive prompt, unless
|
|
15
|
+
// --yes is set (then a missing required value is an error instead of a prompt).
|
|
16
|
+
const { values: flags } = parseArgs({
|
|
17
|
+
options: {
|
|
18
|
+
name: { type: "string" },
|
|
19
|
+
yes: { type: "boolean", short: "y" }
|
|
20
|
+
},
|
|
21
|
+
strict: false,
|
|
22
|
+
allowPositionals: true
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
async function resolveValue(flagValue, flagName, promptConfig) {
|
|
26
|
+
if (flagValue !== undefined && flagValue !== "") return flagValue;
|
|
27
|
+
if (flags.yes) {
|
|
28
|
+
console.log(
|
|
29
|
+
chalk.red(
|
|
30
|
+
`Missing required option --${flagName} (running non-interactively with --yes).`
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const answer = await inquirer.prompt([promptConfig]);
|
|
36
|
+
return answer[promptConfig.name];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const projectName = (
|
|
40
|
+
await resolveValue(flags.name, "name", {
|
|
41
|
+
type: "input",
|
|
42
|
+
name: "projectName",
|
|
43
|
+
message: "Enter the project name: "
|
|
44
|
+
})
|
|
45
|
+
).trim();
|
|
46
|
+
|
|
47
|
+
// Make sure a directory with the supplied name doesn't exist already...
|
|
48
|
+
const currentWorkingDirectory = process.cwd(); // This is the directory from which the script was invoked.
|
|
49
|
+
const projectFolderPath = join(currentWorkingDirectory, projectName);
|
|
50
|
+
if (fs.existsSync(projectFolderPath)) {
|
|
51
|
+
console.log(
|
|
52
|
+
chalk.red(
|
|
53
|
+
`Error: A directory with the name '${projectName}' already exists in ${currentWorkingDirectory}!
|
|
54
|
+
Please, either,
|
|
55
|
+
1) Supply a new project name.
|
|
56
|
+
2) Remove or rename the existing folder.`
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
} else if (!isValidPackageName(projectName)) {
|
|
61
|
+
console.log(
|
|
62
|
+
chalk.red(
|
|
63
|
+
`Invalid project name, '${projectName}', refer https://docs.npmjs.com/cli/v10/configuring-npm/package-json.`
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
makeDirectory(projectFolderPath);
|
|
70
|
+
|
|
71
|
+
await appScaffolder({
|
|
72
|
+
projectFolderPath,
|
|
73
|
+
projectName
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
console.log(
|
|
77
|
+
chalk.green(
|
|
78
|
+
`\n✓ Created '${projectName}'. Next: cd ${projectName} && npm install`
|
|
79
|
+
)
|
|
80
|
+
);
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kissflow/create-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI that scaffolds a Kissflow custom app project.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-app": "bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"files": [
|
|
14
|
+
"bin",
|
|
15
|
+
"scaffolders",
|
|
16
|
+
"package.json",
|
|
17
|
+
"README.md",
|
|
18
|
+
"!./node_modules/**"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"lcnc",
|
|
22
|
+
"OrangeScape",
|
|
23
|
+
"no-code",
|
|
24
|
+
"low-code",
|
|
25
|
+
"platform",
|
|
26
|
+
"react",
|
|
27
|
+
"cli",
|
|
28
|
+
"kissflow",
|
|
29
|
+
"scaffolder",
|
|
30
|
+
"vite",
|
|
31
|
+
"webpack"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18.14.1"
|
|
35
|
+
},
|
|
36
|
+
"author": "",
|
|
37
|
+
"license": "ISC",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"chalk": "5.3.0",
|
|
40
|
+
"ejs": "3.1.9",
|
|
41
|
+
"inquirer": "9.2.13",
|
|
42
|
+
"prettier": "3.2.5"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import path, { join } from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
|
|
4
|
+
import { rename } from "../helpers.js";
|
|
5
|
+
import {
|
|
6
|
+
getAllFilePathsRecursively,
|
|
7
|
+
formatWithPrettier,
|
|
8
|
+
renderFileWithEjs,
|
|
9
|
+
getFileContentUsingFullPath,
|
|
10
|
+
isBinaryFile,
|
|
11
|
+
writeFileWithFolderCreation
|
|
12
|
+
} from "../utils.js";
|
|
13
|
+
|
|
14
|
+
const templateDir = path.resolve(
|
|
15
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
16
|
+
"./template"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
async function appScaffolder({ projectFolderPath, projectName }) {
|
|
20
|
+
const projectTemplateFiles = getAllFilePathsRecursively(templateDir);
|
|
21
|
+
|
|
22
|
+
const templateData = {
|
|
23
|
+
projectName
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
for (const file of projectTemplateFiles) {
|
|
27
|
+
const { fileName, fileFullPath, relativeDirectoryPath } = file;
|
|
28
|
+
const fileContent = getFileContentUsingFullPath(fileFullPath, fileName);
|
|
29
|
+
const newName = rename(fileName);
|
|
30
|
+
const targetFilePath = join(
|
|
31
|
+
projectFolderPath,
|
|
32
|
+
relativeDirectoryPath,
|
|
33
|
+
newName
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (isBinaryFile(fileName)) {
|
|
37
|
+
writeFileWithFolderCreation(targetFilePath, fileContent);
|
|
38
|
+
} else {
|
|
39
|
+
const renderedFileContent = renderFileWithEjs(fileContent, templateData);
|
|
40
|
+
const formattedContent = await formatWithPrettier(
|
|
41
|
+
renderedFileContent,
|
|
42
|
+
targetFilePath
|
|
43
|
+
);
|
|
44
|
+
writeFileWithFolderCreation(targetFilePath, formattedContent);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { appScaffolder };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Building <%= projectName %> (Kissflow App UI)
|
|
2
|
+
|
|
3
|
+
This is a **custom UI for a Kissflow app** — a Vite + React SPA
|
|
4
|
+
(`@kissflow/app-core`) that renders full-screen inside Kissflow and talks to it
|
|
5
|
+
through the Kissflow SDK.
|
|
6
|
+
|
|
7
|
+
## Your role
|
|
8
|
+
|
|
9
|
+
You are helping the developer **build the custom UI for their Kissflow app** —
|
|
10
|
+
screens, components, and data wiring. Treat that as the whole job: understand the
|
|
11
|
+
app's data and what the developer wants, then build and refine pages for it.
|
|
12
|
+
|
|
13
|
+
**Work here:**
|
|
14
|
+
|
|
15
|
+
- `src/pages/**` — the screens (file = route)
|
|
16
|
+
- `src/components/**` — shared UI, the layout/shell
|
|
17
|
+
- `src/**`, styles, and small helpers in `lib/` you author
|
|
18
|
+
|
|
19
|
+
**Do NOT** (out of scope — don't go here unless the developer explicitly asks):
|
|
20
|
+
|
|
21
|
+
- Don't modify `@kissflow/app-core`, the SDK, or anything in `node_modules` — the
|
|
22
|
+
framework is a black box you build **on top of**, not something to "improve".
|
|
23
|
+
- Don't hand-edit `lib/kf-context.md` / `lib/kf-schema.json` — they're generated;
|
|
24
|
+
refresh with `npm run kf:sync`.
|
|
25
|
+
- Don't rewrite `agents/*` or this `CLAUDE.md` — they're your reference, not work
|
|
26
|
+
product.
|
|
27
|
+
- If the framework seems to be missing something, build around it in the app (or
|
|
28
|
+
tell the developer) — don't patch the package.
|
|
29
|
+
|
|
30
|
+
Default to **building the app**. When the request is vague, propose concrete
|
|
31
|
+
screens based on the app's data models (see below) and get building.
|
|
32
|
+
|
|
33
|
+
## Design — original and modern, not a reskin of the demo
|
|
34
|
+
|
|
35
|
+
The bundled **Acme CRM** demo (`src/pages/*`, `src/components/app-shell.jsx`,
|
|
36
|
+
`src/data/*`) only exists to show how routing, the layout, and the SDK wire
|
|
37
|
+
together. **It is not a design template.** Two failure modes to avoid:
|
|
38
|
+
|
|
39
|
+
- **Don't reskin it.** Before building, delete the demo pages/components/data and
|
|
40
|
+
design fresh for _this_ app's domain and data models — a finance approvals app and
|
|
41
|
+
an inventory app should look like different products, not the CRM with new labels.
|
|
42
|
+
Pick the layout from what the app does (not always sidebar + table).
|
|
43
|
+
- **Don't ship dated UI.** Aim for a modern, polished 2025 look — generous
|
|
44
|
+
whitespace, clear type hierarchy, one restrained accent colour, soft depth, real
|
|
45
|
+
hover/empty/loading states.
|
|
46
|
+
|
|
47
|
+
**Read [`agents/design-guidelines.md`](./agents/design-guidelines.md)** before
|
|
48
|
+
building — it has the design tokens, layout patterns, component recipes, and a
|
|
49
|
+
do/don't list. Follow it.
|
|
50
|
+
|
|
51
|
+
## First: know the app's data
|
|
52
|
+
|
|
53
|
+
Before building or changing pages, make sure you know the app's data models and roles:
|
|
54
|
+
|
|
55
|
+
1. Ensure `.env` exists (copy `.env.example`, fill the `KF_*` keys).
|
|
56
|
+
2. Run **`npm run kf:sync`** — pulls this app's schema into `lib/`.
|
|
57
|
+
3. **Read [`lib/kf-context.md`](./lib/kf-context.md)** — the available data models
|
|
58
|
+
(dataforms/processes), their fields, and the app's roles. Build against these;
|
|
59
|
+
don't invent field or model ids. (`lib/kf-schema.json` is the machine-readable copy.)
|
|
60
|
+
|
|
61
|
+
Re-run `npm run kf:sync` whenever the app's models/roles change.
|
|
62
|
+
|
|
63
|
+
## Routing — file-based (`src/pages/**`)
|
|
64
|
+
|
|
65
|
+
A file under `src/pages/` becomes a route. `index.jsx` → `/`, `about.jsx` → `/about`,
|
|
66
|
+
`items/[id].jsx` → `/items/:id` (dynamic). (The demo's `contacts/*` routes are just
|
|
67
|
+
examples — replace them with your app's screens.)
|
|
68
|
+
|
|
69
|
+
Navigate with `<KfLink to="…">` or `const r = useKfRouter(); r.push("…")`. The parent
|
|
70
|
+
Kissflow browser URL mirrors the route automatically — never call the SDK for routing.
|
|
71
|
+
|
|
72
|
+
## Layouts (like Next.js)
|
|
73
|
+
|
|
74
|
+
- **Root layout:** a component passed once via `<KfApp routes={routes} layout={AppShell} />`
|
|
75
|
+
in `src/main.jsx`. It's persistent (renders once; only the route swaps in as
|
|
76
|
+
`children`). The demo's `src/components/app-shell.jsx` is one example — design your
|
|
77
|
+
own shell (or no shell) to fit the app.
|
|
78
|
+
- **Section layout:** a file next to a folder of the same name (e.g.
|
|
79
|
+
`src/pages/contacts.jsx` beside `src/pages/contacts/`) wraps that section — render
|
|
80
|
+
an `<Outlet/>`.
|
|
81
|
+
- A page sets the shell header with `usePageTitle("Contacts")`.
|
|
82
|
+
|
|
83
|
+
## Talking to Kissflow (in the browser)
|
|
84
|
+
|
|
85
|
+
```jsx
|
|
86
|
+
import { useKf } from "@kissflow/app-core";
|
|
87
|
+
const kf = useKf(); // initialized SDK
|
|
88
|
+
kf.user;
|
|
89
|
+
kf.account; // current user / account
|
|
90
|
+
const form = kf.app.getDataform("<DataformId>"); // a data model handle
|
|
91
|
+
const { Data } = await form.getItems();
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Read [`agents/kissflow-sdk.md`](./agents/kissflow-sdk.md)** for the full SDK API —
|
|
95
|
+
dataform / process / board CRUD, decision tables, app & page variables, `kf.client`
|
|
96
|
+
(toasts, confirm), `kf.formatter`, and `kf.api`. Combine it with `lib/kf-context.md`
|
|
97
|
+
(the actual model/field/role ids) to write correct data calls.
|
|
98
|
+
|
|
99
|
+
## Conventions
|
|
100
|
+
|
|
101
|
+
- Pure client SPA — **no SSR, no server code, no data fetching at build time**. Each
|
|
102
|
+
page is `"use client"`-style React; fetch data at runtime via `kf.api`.
|
|
103
|
+
- Keep pages in `src/pages/`, shared UI in `src/components/`, helpers in `src/`/`lib/`.
|
|
104
|
+
- Run `npm run dev` (https://localhost:3000) to preview; `npm run zip` to package for upload.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# <%= projectName %>
|
|
2
|
+
|
|
3
|
+
A full custom UI for your Kissflow app, built with
|
|
4
|
+
[`@kissflow/app-core`](https://www.npmjs.com/package/@kissflow/app-core) — a Vite +
|
|
5
|
+
React framework with **folder-based routing** (`src/pages/**`) that renders inside
|
|
6
|
+
Kissflow and keeps the browser URL in sync with your routes.
|
|
7
|
+
|
|
8
|
+
## Develop
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install
|
|
12
|
+
npm run dev # https://localhost:3000
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then in Kissflow, open your app → **Settings → Custom UI**, toggle it on,
|
|
16
|
+
paste `https://localhost:3000`, and Save. Open the app — your UI renders full-screen
|
|
17
|
+
under `/application/<your-app-id>/ui`.
|
|
18
|
+
|
|
19
|
+
## Routing
|
|
20
|
+
|
|
21
|
+
Add a file under `src/pages/`:
|
|
22
|
+
|
|
23
|
+
| File | Route |
|
|
24
|
+
| ------------------------------ | --------------- |
|
|
25
|
+
| `src/pages/index.jsx` | `/` |
|
|
26
|
+
| `src/pages/contacts/index.jsx` | `/contacts` |
|
|
27
|
+
| `src/pages/contacts/[id].jsx` | `/contacts/:id` |
|
|
28
|
+
| `src/pages/settings.jsx` | `/settings` |
|
|
29
|
+
|
|
30
|
+
Navigate with `<KfLink to="/contacts">` or `useKfRouter().push("/contacts")`. The parent
|
|
31
|
+
Kissflow URL mirrors the route automatically.
|
|
32
|
+
|
|
33
|
+
This project ships with a small **Acme CRM** demo (dashboard, searchable contacts,
|
|
34
|
+
a dynamic contact detail route, and a settings page using the live SDK). Replace
|
|
35
|
+
the contents of `src/pages/` with your own app.
|
|
36
|
+
|
|
37
|
+
## Use the Kissflow SDK
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
import { useKf } from "@kissflow/app-core";
|
|
41
|
+
|
|
42
|
+
function MyComponent() {
|
|
43
|
+
const kf = useKf();
|
|
44
|
+
// kf.user, kf.account, kf.app, kf.api(...), ...
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Ship it
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run zip # builds + produces <%= projectName %>.zip
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Upload the zip in **Settings → Custom UI** (Zip mode) instead of a dev URL.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Copy to .env and fill in. Used by `npm run kf:sync` to pull this app's data
|
|
2
|
+
# models + roles into lib/. These are server-to-server ADMIN access keys — keep
|
|
3
|
+
# .env out of git (it is gitignored). They are NOT used by the running UI.
|
|
4
|
+
|
|
5
|
+
# Kissflow domain, e.g. dev-play.kissflow.com (no protocol)
|
|
6
|
+
KF_DOMAIN=
|
|
7
|
+
KF_ACCOUNT_ID=
|
|
8
|
+
KF_APP_ID=
|
|
9
|
+
KF_ACCESS_KEY_ID=
|
|
10
|
+
KF_ACCESS_KEY_SECRET=
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= projectName %>",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"zip": "node scripts/zip.js",
|
|
11
|
+
"kf:sync": "kf-sync",
|
|
12
|
+
"kf:import": "kf-import-page"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@kissflow/app-core": "latest",
|
|
16
|
+
"@radix-ui/react-accordion": "^1.2.14",
|
|
17
|
+
"@radix-ui/react-avatar": "^1.2.0",
|
|
18
|
+
"@radix-ui/react-checkbox": "^1.3.5",
|
|
19
|
+
"@radix-ui/react-dialog": "^1.1.17",
|
|
20
|
+
"@radix-ui/react-dropdown-menu": "^2.1.18",
|
|
21
|
+
"@radix-ui/react-label": "^2.1.10",
|
|
22
|
+
"@radix-ui/react-popover": "^1.1.17",
|
|
23
|
+
"@radix-ui/react-radio-group": "^1.3.8",
|
|
24
|
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
25
|
+
"@radix-ui/react-select": "^2.3.1",
|
|
26
|
+
"@radix-ui/react-separator": "^1.1.10",
|
|
27
|
+
"@radix-ui/react-slider": "^1.3.6",
|
|
28
|
+
"@radix-ui/react-slot": "^1.3.0",
|
|
29
|
+
"@radix-ui/react-switch": "^1.3.1",
|
|
30
|
+
"@radix-ui/react-tabs": "^1.1.15",
|
|
31
|
+
"@radix-ui/react-tooltip": "^1.2.10",
|
|
32
|
+
"class-variance-authority": "^0.7.1",
|
|
33
|
+
"clsx": "^2.1.1",
|
|
34
|
+
"cmdk": "^1.1.1",
|
|
35
|
+
"date-fns": "^4.4.0",
|
|
36
|
+
"lucide-react": "^1.21.0",
|
|
37
|
+
"radix-ui": "^1.6.0",
|
|
38
|
+
"react": "^19.0.0",
|
|
39
|
+
"react-day-picker": "^10.0.1",
|
|
40
|
+
"react-dom": "^19.0.0",
|
|
41
|
+
"react-router-dom": "^6.22.0",
|
|
42
|
+
"recharts": "3.8.0",
|
|
43
|
+
"sonner": "^2.0.7",
|
|
44
|
+
"tailwind-merge": "^3.6.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@tailwindcss/vite": "^4.1.0",
|
|
48
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
49
|
+
"archiver": "^7.0.1",
|
|
50
|
+
"tailwindcss": "^4.1.0",
|
|
51
|
+
"tw-animate-css": "^1.4.0",
|
|
52
|
+
"vite": "^5.1.6",
|
|
53
|
+
"vite-plugin-pages": "^0.32.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Design guidelines (read before building UI)
|
|
2
|
+
|
|
3
|
+
Two rules above all:
|
|
4
|
+
|
|
5
|
+
1. **Everything you can SEE is a *wiring reference* — build the app's own UI, don't inherit the demo.**
|
|
6
|
+
The Acme dashboard (`src/pages/*`, `src/data/*`) **and the shell** (`src/components/app-shell.jsx`)
|
|
7
|
+
exist only to show HOW the pieces connect — routing, the `<KfApp layout=…>` mechanism, navigation
|
|
8
|
+
(`NAV_ITEMS` → `KfLink` / `useKfRouter`), the theme system, dark mode, the mobile drawer, the SDK.
|
|
9
|
+
**None of it is a base to tweak.** Before building: **delete `src/pages/*` + `src/data/*`, and
|
|
10
|
+
rebuild `src/components/app-shell.jsx` from scratch** for THIS app. Learn the nav + global wiring
|
|
11
|
+
from the default, then design your own shell and screens. A finance-approvals app and a
|
|
12
|
+
field-inspection app must look like **different products** — not the demo with renamed labels and
|
|
13
|
+
a recoloured sidebar.
|
|
14
|
+
|
|
15
|
+
**The only things you keep as-is:** the shadcn/ui primitives in `src/components/ui/*` (your
|
|
16
|
+
component library) and the app-core framework wiring (`KfApp` / `layout`, `KfLink`, `useKfRouter`,
|
|
17
|
+
the theme registry, the dynamic `Form` engine). The shell, the navigation, the pages, and how a
|
|
18
|
+
record form is presented are **all yours to design** — see "Build the app's shell + record form".
|
|
19
|
+
|
|
20
|
+
2. **Design for a 2026 bar.** Generated UIs tend to look dated. Hit the bar below.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## You start with shadcn/ui — use it
|
|
25
|
+
|
|
26
|
+
This project ships **shadcn/ui** (New York style) pre-installed in `src/components/ui/*`:
|
|
27
|
+
Button, Card, Table, Dialog, Sheet, Select, Command (⌘K / combobox), DropdownMenu,
|
|
28
|
+
Popover, Tabs, Badge, Avatar, Calendar / DatePicker, Checkbox, Switch, Input, Label,
|
|
29
|
+
Tooltip, Accordion, Separator, Skeleton, Sonner (toasts), and Chart (recharts wrapper).
|
|
30
|
+
|
|
31
|
+
**This is your quick-start palette — reach for it first** so you get a polished,
|
|
32
|
+
accessible, consistent result out of the box. Compose and extend these freely, and
|
|
33
|
+
**build your own components on top** when the domain needs something shadcn doesn't have
|
|
34
|
+
(a kanban board, a gantt, a map, a specialised record card) — style those with the same
|
|
35
|
+
tokens below so they sit alongside the primitives seamlessly.
|
|
36
|
+
|
|
37
|
+
- Need a component that isn't here? Add it: `npx shadcn@latest add <name>`.
|
|
38
|
+
- Charts: use **recharts** via the shadcn `Chart` wrapper (`ui/chart.jsx`) — it themes
|
|
39
|
+
series with `--chart-1..5` for you.
|
|
40
|
+
|
|
41
|
+
## Colour + theme — tokens only, never hex
|
|
42
|
+
|
|
43
|
+
The palette is a **token system** (shadcn + Tailwind v4, oklch) already wired in
|
|
44
|
+
`src/index.css`. **Never hardcode colours** (`#4f46e5`, `bg-[#f8fafc]`) — always use the
|
|
45
|
+
semantic Tailwind utilities so light/dark and theme-switching just work:
|
|
46
|
+
|
|
47
|
+
| use | utility |
|
|
48
|
+
|---|---|
|
|
49
|
+
| page / app background | `bg-background` `text-foreground` |
|
|
50
|
+
| cards, panels, popovers | `bg-card` / `bg-popover` (+ `-foreground`) |
|
|
51
|
+
| muted / secondary text | `text-muted-foreground` |
|
|
52
|
+
| primary action / active | `bg-primary text-primary-foreground` |
|
|
53
|
+
| subtle fills / hovers | `bg-muted` / `bg-accent` |
|
|
54
|
+
| borders, inputs, rings | `border-border` `ring-ring` |
|
|
55
|
+
| destructive | `bg-destructive` / `text-destructive` |
|
|
56
|
+
| chart series | `var(--chart-1..5)` (via the Chart wrapper) |
|
|
57
|
+
|
|
58
|
+
**Accent + light/dark are switchable** via the theme registry — see
|
|
59
|
+
[`theming.md`](./theming.md). Presets (violet, blue, emerald, rose, amber, orange) each
|
|
60
|
+
recolour `--primary` / `--ring` / `--sidebar` / `--chart-*` in light **and** dark by
|
|
61
|
+
setting `data-theme` on `<html>`. Pick the preset that fits the app's brand (or add one)
|
|
62
|
+
instead of hand-picking hex. Dark mode is `class="dark"` on `<html>` — already toggled in
|
|
63
|
+
the shell.
|
|
64
|
+
|
|
65
|
+
## What makes it look current — do / don't
|
|
66
|
+
|
|
67
|
+
**Do**
|
|
68
|
+
- Generous whitespace + a clear type hierarchy (big bold titles, calm body, muted meta).
|
|
69
|
+
- Cards with a **subtle** border *or* soft shadow — not both heavy (`border bg-card`).
|
|
70
|
+
- Restrained colour: mostly neutral tokens; `primary` only for primary actions / active state.
|
|
71
|
+
- Rounded corners (shadcn's `rounded-lg` / `rounded-md`; pills = `rounded-full` for tags).
|
|
72
|
+
- Real **states**: hover, `focus-visible` ring, disabled, empty, loading, error.
|
|
73
|
+
- **Skeleton** loaders (`ui/skeleton`) for content, not centred spinners.
|
|
74
|
+
- Status as soft **`Badge`s** (tinted variants), never raw coloured text.
|
|
75
|
+
- Micro-interactions: 120–160ms transitions on hover/press; `transform` / `opacity` only.
|
|
76
|
+
- Responsive: usable narrow — the iframe can be mobile (`kf.env.isMobile`); the shell
|
|
77
|
+
already has a mobile drawer, follow that pattern.
|
|
78
|
+
|
|
79
|
+
**Don't (these read as dated)**
|
|
80
|
+
- Hardcoded hex / arbitrary `bg-[#...]` — breaks theming + dark mode.
|
|
81
|
+
- Heavy 1–2px gray borders on everything / boxes-in-boxes.
|
|
82
|
+
- Cramped spacing, tiny gray text everywhere.
|
|
83
|
+
- Raw browser `<table>` / `<button>` / `<select>` / `<input>` — use the shadcn equivalents.
|
|
84
|
+
- Glossy gradients, bevels, drop-shadow text, pure-black (`#000`) on white.
|
|
85
|
+
- `alert()` / `confirm()` — use a `sonner` toast or a shadcn `Dialog`, or the SDK's
|
|
86
|
+
`kf.client.showInfo` / `showConfirm`.
|
|
87
|
+
|
|
88
|
+
## Structure — start from the domain, not a layout
|
|
89
|
+
|
|
90
|
+
Pick the structure from what the app *does* and its data — don't default to
|
|
91
|
+
"sidebar + table" every time:
|
|
92
|
+
|
|
93
|
+
- A few records, action-oriented → **dashboard / card grid** with primary actions.
|
|
94
|
+
- One main list users live in → **list/detail** (master-detail), maybe split-pane.
|
|
95
|
+
- A workflow / approval process → **task inbox + record view** with a clear status rail.
|
|
96
|
+
- Reporting → **metric cards + charts**, filters up top.
|
|
97
|
+
- A single entity to manage → **focused form / detail page**, no nav at all.
|
|
98
|
+
|
|
99
|
+
Match navigation to scope: 1–2 areas need no sidebar (just a header); 3+ areas warrant
|
|
100
|
+
a sidebar or top tabs. Don't add chrome you don't need.
|
|
101
|
+
|
|
102
|
+
## Build the app's shell + record form — MANDATORY (don't inherit the defaults)
|
|
103
|
+
|
|
104
|
+
The scaffold's `app-shell.jsx` and the dynamic `Form` are **references + working defaults, not a
|
|
105
|
+
base to tweak.** The #1 reason generated apps all look the same is shipping the default shell with
|
|
106
|
+
new colours and nav items. Instead:
|
|
107
|
+
|
|
108
|
+
- **App shell (`src/components/app-shell.jsx`) — REBUILD it for this app.** The default only exists
|
|
109
|
+
to show the mechanics (the `layout` prop, `NAV_ITEMS` → `KfLink`, dark toggle, theme switcher,
|
|
110
|
+
mobile drawer). Design the shell the app actually needs: pick the pattern from the audience + use
|
|
111
|
+
case — a consumer / mobile app → a **bottom tab-bar**; an admin / ops tool → a **sidebar**; a
|
|
112
|
+
focused single-purpose tool → a **top header** (or no chrome at all — see Structure). Design the
|
|
113
|
+
brand, the nav shape + labels + icons, and the global chrome (search, profile, notifications, a
|
|
114
|
+
dev role switcher — see below) from the domain. **Two different apps must have visibly different
|
|
115
|
+
shells.** Litmus test: if your shell is the default sidebar with a new logo + colours, you haven't
|
|
116
|
+
done this.
|
|
117
|
+
- **Global concerns live in the shell** — app-wide providers, the theme + dark toggle, the
|
|
118
|
+
top-level navigation, and (in dev) the role switcher. Anything every screen needs goes here.
|
|
119
|
+
- **Record form (`src/components/form`) — design it per record.** The dynamic Form renders every
|
|
120
|
+
field generically; that's a functional default, not a designed form. For each record you MUST
|
|
121
|
+
group + order fields into meaningful **sections**, hide the noise, choose the right chrome (inline
|
|
122
|
+
panel vs `Dialog` vs `Sheet` vs full page), and style it with the app's tokens + section headers.
|
|
123
|
+
Never drop the raw default Form into a modal and call it done.
|
|
124
|
+
|
|
125
|
+
## Role-gate the UI — and add a dev role switcher
|
|
126
|
+
|
|
127
|
+
Kissflow apps are multi-role, and each role should get a **different UI** — not the same screen with
|
|
128
|
+
buttons hidden. Gate nav, pages, and actions by role using `kf.user.AppRoles` (role ids/names are in
|
|
129
|
+
`lib/kf-context.md`): a Passenger and an Admin should get different navigation and different screens.
|
|
130
|
+
|
|
131
|
+
To build + test those role-specific views in **dev**, use the SDK's dev-only role switch:
|
|
132
|
+
- `const { roles, currentRoles } = await kf.app.getRoles()` — all app roles + the user's current role(s).
|
|
133
|
+
- `await kf.app.switchRole({ roleId })` (or `{ roleName }`) — switches the active role **live** (the
|
|
134
|
+
platform picks it up, no reload). **Dev accounts only — blocked / no-op in production.**
|
|
135
|
+
|
|
136
|
+
**Put a small role switcher in the shell** (a `Select` / `DropdownMenu` over `roles` that calls
|
|
137
|
+
`switchRole`, then re-fetches) so testers can flip roles in dev. **Guard it to dev:** the methods
|
|
138
|
+
throw outside a dev account, so wrap `getRoles()` in a try/catch and only render the switcher when it
|
|
139
|
+
resolves — it then simply doesn't appear in production.
|
|
140
|
+
|
|
141
|
+
## Data patterns — multi-flow reads & derived metrics
|
|
142
|
+
|
|
143
|
+
Two patterns that keep multi-flow, report-derived apps robust:
|
|
144
|
+
|
|
145
|
+
- **Scope error/empty state to the CORE flow(s) only.** When a page reads **multiple flows**, don't
|
|
146
|
+
aggregate one `error` across all of them and blank the whole page. A permission error on a
|
|
147
|
+
*secondary* lookup — a flow the current role may not be allowed to read (e.g. Category, Supplier) —
|
|
148
|
+
must **degrade to empty / a secondary-error notice, NOT blank the entire page**. Key the page-level
|
|
149
|
+
`ErrorState` on the core flow(s); surface secondary failures as an empty state or an inline
|
|
150
|
+
`secondaryError`. (A role without Category/Supplier access should still see the dashboard, not a
|
|
151
|
+
blanked screen.)
|
|
152
|
+
|
|
153
|
+
- **Derive computed values in ONE shared helper — but prefer platform formulas where they fit.**
|
|
154
|
+
Kissflow **does persist** process-level computed fields and child-table column formulas through
|
|
155
|
+
publish (the old "formulas strip on publish" belief was wrong) — so a clean *per-record* formula
|
|
156
|
+
(a line total, a signed quantity) is best modelled as a **platform computed field**: single source,
|
|
157
|
+
no UI math. Reach for client-side derivation only for values that genuinely aren't on the record —
|
|
158
|
+
**cross-flow rollups** (on-hand across all movements), **report-derived** aggregates, low-stock /
|
|
159
|
+
avg-consumption. For those, put every derivation in one shared **`src/lib/metrics.js`** the whole app
|
|
160
|
+
imports (one canonical on-hand / valuation helper), not recomputed per component — one source of
|
|
161
|
+
truth, one place to fix. (PATTERN — create `metrics.js` per app; not pre-scaffolded.)
|
|
162
|
+
|
|
163
|
+
## Polish checklist (before you call it done)
|
|
164
|
+
|
|
165
|
+
- [ ] Looks nothing like the demo dashboard — and the **shell is purpose-built** (not the default sidebar recoloured).
|
|
166
|
+
- [ ] Nav, pages & actions are **role-gated** (`kf.user.AppRoles`); a **dev role switcher** is in the shell.
|
|
167
|
+
- [ ] Built on shadcn/ui primitives (+ custom components where the domain needs them).
|
|
168
|
+
- [ ] Zero hardcoded colours — semantic tokens only; works in light **and** dark.
|
|
169
|
+
- [ ] Loading + empty + error states for every data view.
|
|
170
|
+
- [ ] `primary` used sparingly; the rest neutral.
|
|
171
|
+
- [ ] Keyboard focus visible; clickable things are real `<button>` / `<a>` (or shadcn).
|
|
172
|
+
- [ ] Reads well on a narrow width.
|