formstack-ui 0.0.1

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 (64) hide show
  1. package/CHANGELOG.md +206 -0
  2. package/LICENSE +21 -0
  3. package/README.md +341 -0
  4. package/dist/bin/index.js +1077 -0
  5. package/dist/bin/registry.js +105 -0
  6. package/dist/components/FormikSchemaForm.d.ts +11 -0
  7. package/dist/components/SchemaForm.d.ts +26 -0
  8. package/dist/components/ThemeSwitcher.d.ts +1 -0
  9. package/dist/components/builder/FormBuilder.d.ts +1 -0
  10. package/dist/components/demo/Documentation.d.ts +1 -0
  11. package/dist/components/demo/StatesGallery.d.ts +1 -0
  12. package/dist/components/form/FormRenderer.d.ts +9 -0
  13. package/dist/components/layout/GridContainer.d.ts +8 -0
  14. package/dist/components/layout/GridItem.d.ts +8 -0
  15. package/dist/components/pages/ChangelogPage.d.ts +1 -0
  16. package/dist/components/pages/DemoPage.d.ts +6 -0
  17. package/dist/components/pages/GuidePage.d.ts +1 -0
  18. package/dist/components/pages/Home.d.ts +1 -0
  19. package/dist/components/pages/ReadmePage.d.ts +1 -0
  20. package/dist/components/pages/TasksPage.d.ts +1 -0
  21. package/dist/components/pages/ThemeOverridesPage.d.ts +1 -0
  22. package/dist/components/playground/ComponentPlayground.d.ts +8 -0
  23. package/dist/components/playground/PlaygroundPage.d.ts +1 -0
  24. package/dist/components/playground/components-config.d.ts +10 -0
  25. package/dist/components/playground/types.d.ts +14 -0
  26. package/dist/components/theme/ThemeContext.d.ts +16 -0
  27. package/dist/components/theme/defaultTheme.d.ts +2 -0
  28. package/dist/components/theme/types.d.ts +38 -0
  29. package/dist/components/ui/Checkbox.d.ts +6 -0
  30. package/dist/components/ui/FileInput.d.ts +12 -0
  31. package/dist/components/ui/Grid.d.ts +18 -0
  32. package/dist/components/ui/RadioGroup.d.ts +16 -0
  33. package/dist/components/ui/Select.d.ts +9 -0
  34. package/dist/components/ui/Switch.d.ts +6 -0
  35. package/dist/components/ui/TextInput.d.ts +6 -0
  36. package/dist/components/ui/Textarea.d.ts +10 -0
  37. package/dist/components/ui/date/Calendar.d.ts +16 -0
  38. package/dist/components/ui/date/DatePicker.d.ts +12 -0
  39. package/dist/components/ui/date/DateRangePicker.d.ts +18 -0
  40. package/dist/components/ui/date/DateTimePicker.d.ts +12 -0
  41. package/dist/components/ui/date/TimePicker.d.ts +12 -0
  42. package/dist/components/ui/date/TimeView.d.ts +7 -0
  43. package/dist/components/ui/date/index.d.ts +4 -0
  44. package/dist/components/ui/field/BaseField.d.ts +16 -0
  45. package/dist/components/ui/field/ErrorTooltip.d.ts +6 -0
  46. package/dist/components/ui/field/LabelWrapper.d.ts +14 -0
  47. package/dist/components/ui/field/types.d.ts +15 -0
  48. package/dist/components/ui/select/Autocomplete.d.ts +15 -0
  49. package/dist/components/ui/select/Chip.d.ts +7 -0
  50. package/dist/components/ui/select/types.d.ts +5 -0
  51. package/dist/context/ThemeContext.d.ts +14 -0
  52. package/dist/hooks/useDebounce.d.ts +1 -0
  53. package/dist/hooks/useForm.d.ts +28 -0
  54. package/dist/index.js +11801 -0
  55. package/dist/lib/demo-schemas.d.ts +2 -0
  56. package/dist/lib/index.d.ts +17 -0
  57. package/dist/lib/schema-helpers.d.ts +29 -0
  58. package/dist/types/schema.d.ts +136 -0
  59. package/dist/utils/date-utils.d.ts +10 -0
  60. package/dist/utils/dependencies.d.ts +2 -0
  61. package/dist/utils/validation.d.ts +7 -0
  62. package/dist/utils/yup-validation.d.ts +7 -0
  63. package/dist/vite.svg +1 -0
  64. package/package.json +130 -0
@@ -0,0 +1,2 @@
1
+ import type { FormSchema } from "../types/schema";
2
+ export declare const KITCHEN_SINK_SCHEMA: FormSchema;
@@ -0,0 +1,17 @@
1
+ export { SchemaForm } from "../components/SchemaForm";
2
+ export { FormikSchemaForm } from "../components/FormikSchemaForm";
3
+ export { FormBuilder } from "../components/builder/FormBuilder";
4
+ export type { FormSchema } from "../types/schema";
5
+ export { GridContainer, GridItem } from "../components/ui/Grid";
6
+ export { TextInput } from "../components/ui/TextInput";
7
+ export { Textarea } from "../components/ui/Textarea";
8
+ export { Select } from "../components/ui/Select";
9
+ export { Checkbox } from "../components/ui/Checkbox";
10
+ export { Switch } from "../components/ui/Switch";
11
+ export { RadioGroup } from "../components/ui/RadioGroup";
12
+ export { Autocomplete } from "../components/ui/select/Autocomplete";
13
+ export { FileInput } from "../components/ui/FileInput";
14
+ export { DatePicker, TimePicker, DateTimePicker, DateRangePicker } from "../components/ui/date";
15
+ export { ThemeProvider, useFormTheme } from "../components/theme/ThemeContext";
16
+ export type { FormTheme } from "../components/theme/types";
17
+ export { defaultTheme } from "../components/theme/defaultTheme";
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ import type { FormSchema, FieldSchema } from "../types/schema";
3
+ /**
4
+ * Enhanced getByPath: Checks for flat key FIRST (best for dot-notated names in flat state)
5
+ * Falls back to nested access if flat key is not found.
6
+ */
7
+ export declare const getByPath: (obj: any, path: string) => any;
8
+ export declare function checkVisibility(field: FieldSchema, values: any): boolean;
9
+ /**
10
+ * Check if field should be disabled based on disable rules
11
+ */
12
+ export declare function checkDisabled(field: FieldSchema, values: any): boolean;
13
+ /**
14
+ * Check if field value should be cleared based on clear value rules
15
+ */
16
+ export declare function checkShouldClearValue(field: FieldSchema, values: any, previousValues?: any): boolean;
17
+ /**
18
+ * Generates flat defaults for fields, even those with dot-notation
19
+ */
20
+ export declare function generateDefaultValues(schema: FormSchema): Record<string, any>;
21
+ /**
22
+ * Generates a Zod schema that treats field.name as a flat key.
23
+ * Strictly follows the order: Base Type -> Basic Rules -> Special Refinement (Required) -> Optionality.
24
+ */
25
+ export declare function generateZodSchema(schema: FormSchema): z.ZodObject<Record<string, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
26
+ [x: string]: any;
27
+ }, {
28
+ [x: string]: any;
29
+ }>;
@@ -0,0 +1,136 @@
1
+ export type FieldDirection = "horizontal" | "vertical";
2
+ export interface ResponsiveDirection {
3
+ xs?: FieldDirection;
4
+ sm?: FieldDirection;
5
+ md?: FieldDirection;
6
+ lg?: FieldDirection;
7
+ }
8
+ export type FieldType = "text" | "email" | "url" | "tel" | "number" | "password" | "textarea" | "select" | "autocomplete" | "date" | "time" | "datetime" | "daterange" | "checkbox" | "switch" | "radio" | "file";
9
+ export interface SelectOption {
10
+ label: string;
11
+ value: string | number;
12
+ }
13
+ export interface ValidationRule {
14
+ type: "required" | "min" | "max" | "minLength" | "maxLength" | "length" | "email" | "url" | "pattern" | "step" | "regex" | "custom" | "fileSize" | "fileType" | "minDate" | "maxDate" | "integer" | "positive" | "negative" | "nonZero";
15
+ value?: any;
16
+ message?: string;
17
+ }
18
+ export interface GridProps {
19
+ colSpan?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
20
+ xs?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
21
+ sm?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
22
+ md?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
23
+ lg?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
24
+ rowSpan?: number;
25
+ }
26
+ export interface VisibilityRule {
27
+ field: string;
28
+ operator: "eq" | "neq" | "in" | "contains" | "gt" | "lt" | "nin" | "changed";
29
+ value: any;
30
+ }
31
+ export interface FieldSchema {
32
+ id: string;
33
+ name: string;
34
+ type: FieldType;
35
+ label: string;
36
+ placeholder?: string;
37
+ defaultValue?: any;
38
+ helperText?: string;
39
+ errorMessage?: string;
40
+ options?: SelectOption[];
41
+ multiple?: boolean;
42
+ restrictInput?: boolean;
43
+ clearable?: boolean;
44
+ asyncUrl?: string;
45
+ startAdornment?: string;
46
+ endAdornment?: string;
47
+ direction?: FieldDirection | ResponsiveDirection;
48
+ rows?: number;
49
+ minRows?: number;
50
+ maxRows?: number;
51
+ resize?: "none" | "vertical" | "horizontal" | "both";
52
+ format?: string;
53
+ accept?: string;
54
+ maxSize?: number;
55
+ min?: number;
56
+ max?: number;
57
+ step?: number;
58
+ minLength?: number;
59
+ maxLength?: number;
60
+ pattern?: string;
61
+ autocomplete?: string;
62
+ inputMode?: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url";
63
+ maxFiles?: number;
64
+ allowedExtensions?: string[];
65
+ previewMode?: "list" | "grid" | "compact";
66
+ minDate?: string;
67
+ maxDate?: string;
68
+ disabledDates?: string[];
69
+ dateFormat?: string;
70
+ timeFormat?: "12h" | "24h";
71
+ searchable?: boolean;
72
+ creatable?: boolean;
73
+ grouped?: boolean;
74
+ virtualScroll?: boolean;
75
+ loadingText?: string;
76
+ noOptionsText?: string;
77
+ autoGrow?: boolean;
78
+ showCharCount?: boolean;
79
+ checkboxLabel?: string;
80
+ indeterminate?: boolean;
81
+ variant?: "outlined" | "filled" | "standard";
82
+ size?: "small" | "medium" | "large";
83
+ color?: "primary" | "secondary" | "success" | "error" | "warning" | "info";
84
+ fullWidth?: boolean;
85
+ dense?: boolean;
86
+ grid?: GridProps;
87
+ disabled?: boolean;
88
+ hidden?: boolean;
89
+ readOnly?: boolean;
90
+ required?: boolean;
91
+ autoFocus?: boolean;
92
+ validation?: ValidationRule[];
93
+ validateOnChange?: boolean;
94
+ validateOnBlur?: boolean;
95
+ debounceValidation?: number;
96
+ visibilityRules?: VisibilityRule[];
97
+ disableRules?: VisibilityRule[];
98
+ clearValueRules?: VisibilityRule[];
99
+ reserveSpace?: boolean;
100
+ tooltip?: string;
101
+ prefix?: string;
102
+ suffix?: string;
103
+ mask?: string;
104
+ transform?: "uppercase" | "lowercase" | "capitalize";
105
+ }
106
+ export interface FormSchema {
107
+ id?: string;
108
+ title?: string;
109
+ description?: string;
110
+ fields: FieldSchema[];
111
+ layout?: {
112
+ columns?: number;
113
+ gap?: number;
114
+ };
115
+ styling?: {
116
+ spacing?: {
117
+ formPadding?: number;
118
+ fieldGap?: number;
119
+ sectionGap?: number;
120
+ };
121
+ responsive?: {
122
+ mobile?: {
123
+ columns?: number;
124
+ gap?: number;
125
+ };
126
+ tablet?: {
127
+ columns?: number;
128
+ gap?: number;
129
+ };
130
+ desktop?: {
131
+ columns?: number;
132
+ gap?: number;
133
+ };
134
+ };
135
+ };
136
+ }
@@ -0,0 +1,10 @@
1
+ export declare const months: string[];
2
+ export declare const daysShort: string[];
3
+ export declare const getDaysInMonth: (year: number, month: number) => number;
4
+ export declare const getFirstDayOfMonth: (year: number, month: number) => number;
5
+ export declare const formatDate: (date: Date | null, formatStr?: string) => string;
6
+ export declare const parseDate: (dateStr: string) => Date | null;
7
+ export declare const isSameDay: (d1: Date | null, d2: Date | null) => boolean;
8
+ export declare const isToday: (d: Date) => boolean;
9
+ export declare const addMonths: (date: Date, monthsToAdd: number) => Date;
10
+ export declare const startOfDay: (date: Date) => Date;
@@ -0,0 +1,2 @@
1
+ import type { FieldSchema } from "@/types/schema";
2
+ export declare const evaluateVisibility: (field: FieldSchema, formData: Record<string, any>) => boolean;
@@ -0,0 +1,7 @@
1
+ import { z } from "zod";
2
+ import type { FormSchema } from "@/types/schema";
3
+ export declare const generateZodSchema: (schema: FormSchema) => z.ZodObject<Record<string, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
4
+ [x: string]: any;
5
+ }, {
6
+ [x: string]: any;
7
+ }>;
@@ -0,0 +1,7 @@
1
+ import * as yup from "yup";
2
+ import type { FormSchema } from "@/types/schema";
3
+ export declare const generateYupSchema: (schema: FormSchema) => yup.ObjectSchema<{
4
+ [x: string]: any;
5
+ }, yup.AnyObject, {
6
+ [x: string]: any;
7
+ }, "">;
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,130 @@
1
+ {
2
+ "name": "formstack-ui",
3
+ "version": "0.0.1",
4
+ "description": "The complete UI framework for building form-driven React applications with visual builder, CLI tools, and enterprise-grade features",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./styles": "./dist/style.css"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE",
20
+ "CHANGELOG.md"
21
+ ],
22
+ "scripts": {
23
+ "dev": "vite",
24
+ "build": "tsc -b && vite build",
25
+ "lint": "eslint .",
26
+ "preview": "vite preview",
27
+ "prepublishOnly": "npm run build:lib",
28
+ "prepare": "husky",
29
+ "predeploy": "npm run build",
30
+ "build:site": "vite build",
31
+ "build:lib": "vite build --config vite.lib.config.ts && tsc -p tsconfig.lib.json && npm run build:cli",
32
+ "build:cli": "tsc -p tsconfig.cli.json",
33
+ "deploy": "gh-pages -d dist-site"
34
+ },
35
+ "bin": {
36
+ "formstack-ui": "dist/bin/index.js",
37
+ "create-formstack-ui": "dist/bin/index.js"
38
+ },
39
+ "keywords": [
40
+ "react",
41
+ "form",
42
+ "form-builder",
43
+ "schema",
44
+ "validation",
45
+ "typescript",
46
+ "tailwind",
47
+ "dynamic-forms",
48
+ "formstack",
49
+ "ui-framework",
50
+ "zod",
51
+ "yup",
52
+ "formik",
53
+ "visual-builder",
54
+ "drag-and-drop",
55
+ "conditional-logic",
56
+ "responsive",
57
+ "accessibility",
58
+ "dark-mode",
59
+ "cli"
60
+ ],
61
+ "author": "Adarsh <adarshatl03@gmail.com>",
62
+ "license": "MIT",
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/formstack-ui/formstack-ui.git"
66
+ },
67
+ "bugs": {
68
+ "url": "https://github.com/formstack-ui/formstack-ui/issues"
69
+ },
70
+ "homepage": "https://formstack-ui.dev",
71
+ "peerDependencies": {
72
+ "formik": ">=2.4.0",
73
+ "react": ">=18.0.0",
74
+ "react-dom": ">=18.0.0",
75
+ "tailwindcss": ">=4.0.0",
76
+ "yup": ">=1.0.0",
77
+ "zod": ">=3.0.0"
78
+ },
79
+ "dependencies": {
80
+ "chalk": "^5.6.2",
81
+ "commander": "^14.0.2",
82
+ "date-fns": "^4.1.0",
83
+ "execa": "^9.6.1",
84
+ "fs-extra": "^11.3.3",
85
+ "lucide-react": "^0.562.0",
86
+ "ora": "^9.0.0",
87
+ "prompts": "^2.4.2",
88
+ "react-router-dom": "^7.12.0"
89
+ },
90
+ "devDependencies": {
91
+ "@eslint/js": "^9.39.1",
92
+ "@tailwindcss/vite": "^4.1.18",
93
+ "@types/fs-extra": "^11.0.4",
94
+ "@types/node": "^24.10.7",
95
+ "@types/prompts": "^2.4.9",
96
+ "@types/react": "^19.2.5",
97
+ "@types/react-dom": "^19.2.3",
98
+ "@vitejs/plugin-react": "^5.1.1",
99
+ "eslint": "^9.39.1",
100
+ "eslint-plugin-react-hooks": "^7.0.1",
101
+ "eslint-plugin-react-refresh": "^0.4.24",
102
+ "formik": "^2.4.9",
103
+ "gh-pages": "^6.3.0",
104
+ "globals": "^16.5.0",
105
+ "husky": "^9.1.7",
106
+ "lint-staged": "^16.2.7",
107
+ "prettier": "^3.7.4",
108
+ "react": "^19.0.0",
109
+ "react-dom": "^19.0.0",
110
+ "tailwindcss": "^4.0.0",
111
+ "typescript": "~5.9.3",
112
+ "typescript-eslint": "^8.46.4",
113
+ "vite": "^7.2.4",
114
+ "yup": "^1.7.1",
115
+ "zod": "^3.24.1"
116
+ },
117
+ "engines": {
118
+ "node": ">=18.0.0",
119
+ "npm": ">=9.0.0"
120
+ },
121
+ "lint-staged": {
122
+ "*.{ts,tsx}": [
123
+ "eslint --fix",
124
+ "tsc --noEmit"
125
+ ],
126
+ "*.{json,md}": [
127
+ "prettier --write"
128
+ ]
129
+ }
130
+ }