@btst/components 0.0.0-stage → 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.
Files changed (161) hide show
  1. package/LICENSE.md +17 -0
  2. package/dist/_private/ui/styles/markdown-editor.css +31 -0
  3. package/dist/auto-form/index.cjs +8 -0
  4. package/dist/auto-form/index.d.cts +26 -0
  5. package/dist/auto-form/index.d.mts +26 -0
  6. package/dist/auto-form/index.d.ts +26 -0
  7. package/dist/auto-form/index.mjs +1 -0
  8. package/dist/empty/index.cjs +12 -0
  9. package/dist/empty/index.d.cts +15 -0
  10. package/dist/empty/index.d.mts +15 -0
  11. package/dist/empty/index.d.ts +15 -0
  12. package/dist/empty/index.mjs +1 -0
  13. package/dist/form-builder/index.cjs +16 -0
  14. package/dist/form-builder/index.d.cts +395 -0
  15. package/dist/form-builder/index.d.mts +395 -0
  16. package/dist/form-builder/index.d.ts +395 -0
  17. package/dist/form-builder/index.mjs +4 -0
  18. package/dist/markdown/index.cjs +9 -0
  19. package/dist/markdown/index.d.cts +46 -0
  20. package/dist/markdown/index.d.mts +46 -0
  21. package/dist/markdown/index.d.ts +46 -0
  22. package/dist/markdown/index.mjs +2 -0
  23. package/dist/multi-select/index.cjs +7 -0
  24. package/dist/multi-select/index.d.cts +78 -0
  25. package/dist/multi-select/index.d.mts +78 -0
  26. package/dist/multi-select/index.d.ts +78 -0
  27. package/dist/multi-select/index.mjs +1 -0
  28. package/dist/search-select/index.cjs +7 -0
  29. package/dist/search-select/index.d.cts +16 -0
  30. package/dist/search-select/index.d.mts +16 -0
  31. package/dist/search-select/index.d.ts +16 -0
  32. package/dist/search-select/index.mjs +1 -0
  33. package/dist/shared/components.BdvBiegH.d.cts +291 -0
  34. package/dist/shared/components.BdvBiegH.d.mts +291 -0
  35. package/dist/shared/components.BdvBiegH.d.ts +291 -0
  36. package/dist/shared/components.CZMWR72v.d.cts +10 -0
  37. package/dist/shared/components.CZMWR72v.d.mts +10 -0
  38. package/dist/shared/components.CZMWR72v.d.ts +10 -0
  39. package/dist/stepped-auto-form/index.cjs +7 -0
  40. package/dist/stepped-auto-form/index.d.cts +37 -0
  41. package/dist/stepped-auto-form/index.d.mts +37 -0
  42. package/dist/stepped-auto-form/index.d.ts +37 -0
  43. package/dist/stepped-auto-form/index.mjs +1 -0
  44. package/dist/style.css +440 -0
  45. package/dist/ui/src/components/accordion.cjs +81 -0
  46. package/dist/ui/src/components/accordion.mjs +62 -0
  47. package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
  48. package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
  49. package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
  50. package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
  51. package/dist/ui/src/components/auto-form/config.cjs +40 -0
  52. package/dist/ui/src/components/auto-form/config.mjs +37 -0
  53. package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
  54. package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
  55. package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
  56. package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
  57. package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
  58. package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
  59. package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
  60. package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
  61. package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
  62. package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
  63. package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
  64. package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
  65. package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
  66. package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
  67. package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
  68. package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
  69. package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
  70. package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
  71. package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
  72. package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
  73. package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
  74. package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
  75. package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
  76. package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
  77. package/dist/ui/src/components/auto-form/index.cjs +102 -0
  78. package/dist/ui/src/components/auto-form/index.mjs +93 -0
  79. package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
  80. package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
  81. package/dist/ui/src/components/auto-form/types.cjs +11 -0
  82. package/dist/ui/src/components/auto-form/types.mjs +9 -0
  83. package/dist/ui/src/components/badge.cjs +42 -0
  84. package/dist/ui/src/components/badge.mjs +39 -0
  85. package/dist/ui/src/components/button.cjs +56 -0
  86. package/dist/ui/src/components/button.mjs +53 -0
  87. package/dist/ui/src/components/calendar.cjs +207 -0
  88. package/dist/ui/src/components/calendar.mjs +190 -0
  89. package/dist/ui/src/components/checkbox.cjs +48 -0
  90. package/dist/ui/src/components/checkbox.mjs +32 -0
  91. package/dist/ui/src/components/command.cjs +118 -0
  92. package/dist/ui/src/components/command.mjs +111 -0
  93. package/dist/ui/src/components/date-picker.cjs +41 -0
  94. package/dist/ui/src/components/date-picker.mjs +39 -0
  95. package/dist/ui/src/components/dialog.cjs +141 -0
  96. package/dist/ui/src/components/dialog.mjs +118 -0
  97. package/dist/ui/src/components/empty.cjs +104 -0
  98. package/dist/ui/src/components/empty.mjs +97 -0
  99. package/dist/ui/src/components/form-builder/canvas.cjs +111 -0
  100. package/dist/ui/src/components/form-builder/canvas.mjs +109 -0
  101. package/dist/ui/src/components/form-builder/components/index.cjs +571 -0
  102. package/dist/ui/src/components/form-builder/components/index.mjs +554 -0
  103. package/dist/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
  104. package/dist/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
  105. package/dist/ui/src/components/form-builder/form-preview.cjs +73 -0
  106. package/dist/ui/src/components/form-builder/form-preview.mjs +71 -0
  107. package/dist/ui/src/components/form-builder/index.cjs +350 -0
  108. package/dist/ui/src/components/form-builder/index.mjs +344 -0
  109. package/dist/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
  110. package/dist/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
  111. package/dist/ui/src/components/form-builder/palette.cjs +52 -0
  112. package/dist/ui/src/components/form-builder/palette.mjs +49 -0
  113. package/dist/ui/src/components/form-builder/schema-utils.cjs +128 -0
  114. package/dist/ui/src/components/form-builder/schema-utils.mjs +122 -0
  115. package/dist/ui/src/components/form-builder/sortable-field.cjs +151 -0
  116. package/dist/ui/src/components/form-builder/sortable-field.mjs +148 -0
  117. package/dist/ui/src/components/form-builder/step-tabs.cjs +180 -0
  118. package/dist/ui/src/components/form-builder/step-tabs.mjs +178 -0
  119. package/dist/ui/src/components/form-builder/types.cjs +7 -0
  120. package/dist/ui/src/components/form-builder/types.mjs +5 -0
  121. package/dist/ui/src/components/form-builder/validation-schemas.cjs +67 -0
  122. package/dist/ui/src/components/form-builder/validation-schemas.mjs +56 -0
  123. package/dist/ui/src/components/form.cjs +120 -0
  124. package/dist/ui/src/components/form.mjs +98 -0
  125. package/dist/ui/src/components/input.cjs +23 -0
  126. package/dist/ui/src/components/input.mjs +21 -0
  127. package/dist/ui/src/components/label.cjs +39 -0
  128. package/dist/ui/src/components/label.mjs +23 -0
  129. package/dist/ui/src/components/markdown-content.cjs +334 -0
  130. package/dist/ui/src/components/markdown-content.mjs +325 -0
  131. package/dist/ui/src/components/markdown-editor.cjs +180 -0
  132. package/dist/ui/src/components/markdown-editor.mjs +178 -0
  133. package/dist/ui/src/components/multi-select.cjs +555 -0
  134. package/dist/ui/src/components/multi-select.mjs +540 -0
  135. package/dist/ui/src/components/popover.cjs +60 -0
  136. package/dist/ui/src/components/popover.mjs +42 -0
  137. package/dist/ui/src/components/radio-group.cjs +62 -0
  138. package/dist/ui/src/components/radio-group.mjs +45 -0
  139. package/dist/ui/src/components/search-select.cjs +99 -0
  140. package/dist/ui/src/components/search-select.mjs +83 -0
  141. package/dist/ui/src/components/select.cjs +161 -0
  142. package/dist/ui/src/components/select.mjs +139 -0
  143. package/dist/ui/src/components/separator.cjs +43 -0
  144. package/dist/ui/src/components/separator.mjs +27 -0
  145. package/dist/ui/src/components/switch.cjs +48 -0
  146. package/dist/ui/src/components/switch.mjs +32 -0
  147. package/dist/ui/src/components/tabs.cjs +84 -0
  148. package/dist/ui/src/components/tabs.mjs +65 -0
  149. package/dist/ui/src/components/textarea.cjs +20 -0
  150. package/dist/ui/src/components/textarea.mjs +18 -0
  151. package/dist/ui/src/hooks/use-debounce.cjs +16 -0
  152. package/dist/ui/src/hooks/use-debounce.mjs +14 -0
  153. package/dist/ui/src/lib/schema-converter.cjs +94 -0
  154. package/dist/ui/src/lib/schema-converter.mjs +92 -0
  155. package/dist/ui/src/lib/throttle.cjs +56 -0
  156. package/dist/ui/src/lib/throttle.mjs +54 -0
  157. package/dist/ui/src/lib/utils.cjs +10 -0
  158. package/dist/ui/src/lib/utils.mjs +8 -0
  159. package/dist/ui.css +131 -0
  160. package/package.json +176 -3
  161. package/README.md +0 -3
@@ -0,0 +1,84 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const TabsPrimitive = require('@radix-ui/react-tabs');
6
+ const utils = require('../lib/utils.cjs');
7
+
8
+ function _interopNamespaceCompat(e) {
9
+ if (e && typeof e === 'object' && 'default' in e) return e;
10
+ const n = Object.create(null);
11
+ if (e) {
12
+ for (const k in e) {
13
+ n[k] = e[k];
14
+ }
15
+ }
16
+ n.default = e;
17
+ return n;
18
+ }
19
+
20
+ const TabsPrimitive__namespace = /*#__PURE__*/_interopNamespaceCompat(TabsPrimitive);
21
+
22
+ function Tabs({
23
+ className,
24
+ ...props
25
+ }) {
26
+ return /* @__PURE__ */ jsxRuntime.jsx(
27
+ TabsPrimitive__namespace.Root,
28
+ {
29
+ "data-slot": "tabs",
30
+ className: utils.cn("flex flex-col gap-2", className),
31
+ ...props
32
+ }
33
+ );
34
+ }
35
+ function TabsList({
36
+ className,
37
+ ...props
38
+ }) {
39
+ return /* @__PURE__ */ jsxRuntime.jsx(
40
+ TabsPrimitive__namespace.List,
41
+ {
42
+ "data-slot": "tabs-list",
43
+ className: utils.cn(
44
+ "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
45
+ className
46
+ ),
47
+ ...props
48
+ }
49
+ );
50
+ }
51
+ function TabsTrigger({
52
+ className,
53
+ ...props
54
+ }) {
55
+ return /* @__PURE__ */ jsxRuntime.jsx(
56
+ TabsPrimitive__namespace.Trigger,
57
+ {
58
+ "data-slot": "tabs-trigger",
59
+ className: utils.cn(
60
+ "data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
61
+ className
62
+ ),
63
+ ...props
64
+ }
65
+ );
66
+ }
67
+ function TabsContent({
68
+ className,
69
+ ...props
70
+ }) {
71
+ return /* @__PURE__ */ jsxRuntime.jsx(
72
+ TabsPrimitive__namespace.Content,
73
+ {
74
+ "data-slot": "tabs-content",
75
+ className: utils.cn("flex-1 outline-none", className),
76
+ ...props
77
+ }
78
+ );
79
+ }
80
+
81
+ exports.Tabs = Tabs;
82
+ exports.TabsContent = TabsContent;
83
+ exports.TabsList = TabsList;
84
+ exports.TabsTrigger = TabsTrigger;
@@ -0,0 +1,65 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
4
+ import { cn } from '../lib/utils.mjs';
5
+
6
+ function Tabs({
7
+ className,
8
+ ...props
9
+ }) {
10
+ return /* @__PURE__ */ jsx(
11
+ TabsPrimitive.Root,
12
+ {
13
+ "data-slot": "tabs",
14
+ className: cn("flex flex-col gap-2", className),
15
+ ...props
16
+ }
17
+ );
18
+ }
19
+ function TabsList({
20
+ className,
21
+ ...props
22
+ }) {
23
+ return /* @__PURE__ */ jsx(
24
+ TabsPrimitive.List,
25
+ {
26
+ "data-slot": "tabs-list",
27
+ className: cn(
28
+ "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
29
+ className
30
+ ),
31
+ ...props
32
+ }
33
+ );
34
+ }
35
+ function TabsTrigger({
36
+ className,
37
+ ...props
38
+ }) {
39
+ return /* @__PURE__ */ jsx(
40
+ TabsPrimitive.Trigger,
41
+ {
42
+ "data-slot": "tabs-trigger",
43
+ className: cn(
44
+ "data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
45
+ className
46
+ ),
47
+ ...props
48
+ }
49
+ );
50
+ }
51
+ function TabsContent({
52
+ className,
53
+ ...props
54
+ }) {
55
+ return /* @__PURE__ */ jsx(
56
+ TabsPrimitive.Content,
57
+ {
58
+ "data-slot": "tabs-content",
59
+ className: cn("flex-1 outline-none", className),
60
+ ...props
61
+ }
62
+ );
63
+ }
64
+
65
+ export { Tabs, TabsContent, TabsList, TabsTrigger };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ const jsxRuntime = require('react/jsx-runtime');
4
+ const utils = require('../lib/utils.cjs');
5
+
6
+ function Textarea({ className, ...props }) {
7
+ return /* @__PURE__ */ jsxRuntime.jsx(
8
+ "textarea",
9
+ {
10
+ "data-slot": "textarea",
11
+ className: utils.cn(
12
+ "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
13
+ className
14
+ ),
15
+ ...props
16
+ }
17
+ );
18
+ }
19
+
20
+ exports.Textarea = Textarea;
@@ -0,0 +1,18 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { cn } from '../lib/utils.mjs';
3
+
4
+ function Textarea({ className, ...props }) {
5
+ return /* @__PURE__ */ jsx(
6
+ "textarea",
7
+ {
8
+ "data-slot": "textarea",
9
+ className: cn(
10
+ "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
11
+ className
12
+ ),
13
+ ...props
14
+ }
15
+ );
16
+ }
17
+
18
+ export { Textarea };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const React = require('react');
4
+
5
+ function useDebounce(value, delay) {
6
+ const [debouncedValue, setDebouncedValue] = React.useState(value);
7
+ React.useEffect(() => {
8
+ const timer = setTimeout(() => setDebouncedValue(value), delay);
9
+ return () => {
10
+ clearTimeout(timer);
11
+ };
12
+ }, [value, delay]);
13
+ return debouncedValue;
14
+ }
15
+
16
+ exports.useDebounce = useDebounce;
@@ -0,0 +1,14 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ function useDebounce(value, delay) {
4
+ const [debouncedValue, setDebouncedValue] = useState(value);
5
+ useEffect(() => {
6
+ const timer = setTimeout(() => setDebouncedValue(value), delay);
7
+ return () => {
8
+ clearTimeout(timer);
9
+ };
10
+ }, [value, delay]);
11
+ return debouncedValue;
12
+ }
13
+
14
+ export { useDebounce };
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ const z = require('zod');
4
+
5
+ function extractStepGroupMap(jsonSchema) {
6
+ const stepGroupMap = {};
7
+ const properties = jsonSchema.properties;
8
+ if (!properties) return stepGroupMap;
9
+ for (const [fieldName, fieldSchema] of Object.entries(properties)) {
10
+ if (typeof fieldSchema.stepGroup === "number") {
11
+ stepGroupMap[fieldName] = fieldSchema.stepGroup;
12
+ }
13
+ }
14
+ return stepGroupMap;
15
+ }
16
+ function findDateFieldsWithConstraints(jsonSchema) {
17
+ const dateFields = {};
18
+ const properties = jsonSchema.properties;
19
+ if (!properties) return dateFields;
20
+ for (const [key, prop] of Object.entries(properties)) {
21
+ if (prop.type === "string" && prop.format === "date-time") {
22
+ if (prop.formatMinimum || prop.formatMaximum) {
23
+ dateFields[key] = {
24
+ min: prop.formatMinimum,
25
+ max: prop.formatMaximum
26
+ };
27
+ }
28
+ }
29
+ }
30
+ return dateFields;
31
+ }
32
+ function addDateValidations(schema, dateFieldsWithConstraints) {
33
+ if (Object.keys(dateFieldsWithConstraints).length === 0) {
34
+ return schema;
35
+ }
36
+ return schema.superRefine((data, ctx) => {
37
+ for (const [key, constraints] of Object.entries(dateFieldsWithConstraints)) {
38
+ const value = data[key];
39
+ if (value === void 0 || value === null || value === "") continue;
40
+ const dateValue = new Date(value);
41
+ if (isNaN(dateValue.getTime())) {
42
+ ctx.addIssue({
43
+ code: z.z.ZodIssueCode.custom,
44
+ message: "Invalid date",
45
+ path: [key]
46
+ });
47
+ continue;
48
+ }
49
+ if (constraints.min) {
50
+ const minDate = new Date(constraints.min);
51
+ if (dateValue < minDate) {
52
+ ctx.addIssue({
53
+ code: z.z.ZodIssueCode.custom,
54
+ message: `Date must be after ${minDate.toLocaleDateString()}`,
55
+ path: [key]
56
+ });
57
+ }
58
+ }
59
+ if (constraints.max) {
60
+ const maxDate = new Date(constraints.max);
61
+ if (dateValue > maxDate) {
62
+ ctx.addIssue({
63
+ code: z.z.ZodIssueCode.custom,
64
+ message: `Date must be before ${maxDate.toLocaleDateString()}`,
65
+ path: [key]
66
+ });
67
+ }
68
+ }
69
+ }
70
+ });
71
+ }
72
+ function attachStepsMetadata(schema, jsonSchema) {
73
+ const steps = jsonSchema.steps;
74
+ if (!steps || steps.length === 0) {
75
+ return schema;
76
+ }
77
+ const stepGroupMap = jsonSchema.stepGroupMap ?? extractStepGroupMap(jsonSchema);
78
+ return schema.meta({
79
+ steps,
80
+ stepGroupMap
81
+ });
82
+ }
83
+ function formSchemaToZod(jsonSchema) {
84
+ let schema = z.z.fromJSONSchema(jsonSchema);
85
+ if (schema && typeof schema.passthrough === "function") {
86
+ schema = schema.passthrough();
87
+ }
88
+ const dateFieldsWithConstraints = findDateFieldsWithConstraints(jsonSchema);
89
+ schema = addDateValidations(schema, dateFieldsWithConstraints);
90
+ schema = attachStepsMetadata(schema, jsonSchema);
91
+ return schema;
92
+ }
93
+
94
+ exports.formSchemaToZod = formSchemaToZod;
@@ -0,0 +1,92 @@
1
+ import { z } from 'zod';
2
+
3
+ function extractStepGroupMap(jsonSchema) {
4
+ const stepGroupMap = {};
5
+ const properties = jsonSchema.properties;
6
+ if (!properties) return stepGroupMap;
7
+ for (const [fieldName, fieldSchema] of Object.entries(properties)) {
8
+ if (typeof fieldSchema.stepGroup === "number") {
9
+ stepGroupMap[fieldName] = fieldSchema.stepGroup;
10
+ }
11
+ }
12
+ return stepGroupMap;
13
+ }
14
+ function findDateFieldsWithConstraints(jsonSchema) {
15
+ const dateFields = {};
16
+ const properties = jsonSchema.properties;
17
+ if (!properties) return dateFields;
18
+ for (const [key, prop] of Object.entries(properties)) {
19
+ if (prop.type === "string" && prop.format === "date-time") {
20
+ if (prop.formatMinimum || prop.formatMaximum) {
21
+ dateFields[key] = {
22
+ min: prop.formatMinimum,
23
+ max: prop.formatMaximum
24
+ };
25
+ }
26
+ }
27
+ }
28
+ return dateFields;
29
+ }
30
+ function addDateValidations(schema, dateFieldsWithConstraints) {
31
+ if (Object.keys(dateFieldsWithConstraints).length === 0) {
32
+ return schema;
33
+ }
34
+ return schema.superRefine((data, ctx) => {
35
+ for (const [key, constraints] of Object.entries(dateFieldsWithConstraints)) {
36
+ const value = data[key];
37
+ if (value === void 0 || value === null || value === "") continue;
38
+ const dateValue = new Date(value);
39
+ if (isNaN(dateValue.getTime())) {
40
+ ctx.addIssue({
41
+ code: z.ZodIssueCode.custom,
42
+ message: "Invalid date",
43
+ path: [key]
44
+ });
45
+ continue;
46
+ }
47
+ if (constraints.min) {
48
+ const minDate = new Date(constraints.min);
49
+ if (dateValue < minDate) {
50
+ ctx.addIssue({
51
+ code: z.ZodIssueCode.custom,
52
+ message: `Date must be after ${minDate.toLocaleDateString()}`,
53
+ path: [key]
54
+ });
55
+ }
56
+ }
57
+ if (constraints.max) {
58
+ const maxDate = new Date(constraints.max);
59
+ if (dateValue > maxDate) {
60
+ ctx.addIssue({
61
+ code: z.ZodIssueCode.custom,
62
+ message: `Date must be before ${maxDate.toLocaleDateString()}`,
63
+ path: [key]
64
+ });
65
+ }
66
+ }
67
+ }
68
+ });
69
+ }
70
+ function attachStepsMetadata(schema, jsonSchema) {
71
+ const steps = jsonSchema.steps;
72
+ if (!steps || steps.length === 0) {
73
+ return schema;
74
+ }
75
+ const stepGroupMap = jsonSchema.stepGroupMap ?? extractStepGroupMap(jsonSchema);
76
+ return schema.meta({
77
+ steps,
78
+ stepGroupMap
79
+ });
80
+ }
81
+ function formSchemaToZod(jsonSchema) {
82
+ let schema = z.fromJSONSchema(jsonSchema);
83
+ if (schema && typeof schema.passthrough === "function") {
84
+ schema = schema.passthrough();
85
+ }
86
+ const dateFieldsWithConstraints = findDateFieldsWithConstraints(jsonSchema);
87
+ schema = addDateValidations(schema, dateFieldsWithConstraints);
88
+ schema = attachStepsMetadata(schema, jsonSchema);
89
+ return schema;
90
+ }
91
+
92
+ export { formSchemaToZod };
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ function throttle(callback, waitMs) {
4
+ let timerId = null;
5
+ let lastInvokeTime = 0;
6
+ let trailingArgs = null;
7
+ const invoke = (args) => {
8
+ lastInvokeTime = Date.now();
9
+ callback(...args);
10
+ };
11
+ const throttled = (...args) => {
12
+ const now = Date.now();
13
+ const remaining = waitMs - (now - lastInvokeTime);
14
+ if (lastInvokeTime === 0) {
15
+ invoke(args);
16
+ return;
17
+ }
18
+ if (remaining <= 0 || remaining > waitMs) {
19
+ if (timerId) {
20
+ clearTimeout(timerId);
21
+ timerId = null;
22
+ }
23
+ invoke(args);
24
+ } else {
25
+ trailingArgs = args;
26
+ if (!timerId) {
27
+ timerId = setTimeout(() => {
28
+ timerId = null;
29
+ if (trailingArgs) {
30
+ invoke(trailingArgs);
31
+ trailingArgs = null;
32
+ }
33
+ }, remaining);
34
+ }
35
+ }
36
+ };
37
+ throttled.cancel = () => {
38
+ if (timerId) {
39
+ clearTimeout(timerId);
40
+ timerId = null;
41
+ }
42
+ trailingArgs = null;
43
+ lastInvokeTime = 0;
44
+ };
45
+ throttled.flush = () => {
46
+ if (timerId && trailingArgs) {
47
+ clearTimeout(timerId);
48
+ timerId = null;
49
+ invoke(trailingArgs);
50
+ trailingArgs = null;
51
+ }
52
+ };
53
+ return throttled;
54
+ }
55
+
56
+ exports.throttle = throttle;
@@ -0,0 +1,54 @@
1
+ function throttle(callback, waitMs) {
2
+ let timerId = null;
3
+ let lastInvokeTime = 0;
4
+ let trailingArgs = null;
5
+ const invoke = (args) => {
6
+ lastInvokeTime = Date.now();
7
+ callback(...args);
8
+ };
9
+ const throttled = (...args) => {
10
+ const now = Date.now();
11
+ const remaining = waitMs - (now - lastInvokeTime);
12
+ if (lastInvokeTime === 0) {
13
+ invoke(args);
14
+ return;
15
+ }
16
+ if (remaining <= 0 || remaining > waitMs) {
17
+ if (timerId) {
18
+ clearTimeout(timerId);
19
+ timerId = null;
20
+ }
21
+ invoke(args);
22
+ } else {
23
+ trailingArgs = args;
24
+ if (!timerId) {
25
+ timerId = setTimeout(() => {
26
+ timerId = null;
27
+ if (trailingArgs) {
28
+ invoke(trailingArgs);
29
+ trailingArgs = null;
30
+ }
31
+ }, remaining);
32
+ }
33
+ }
34
+ };
35
+ throttled.cancel = () => {
36
+ if (timerId) {
37
+ clearTimeout(timerId);
38
+ timerId = null;
39
+ }
40
+ trailingArgs = null;
41
+ lastInvokeTime = 0;
42
+ };
43
+ throttled.flush = () => {
44
+ if (timerId && trailingArgs) {
45
+ clearTimeout(timerId);
46
+ timerId = null;
47
+ invoke(trailingArgs);
48
+ trailingArgs = null;
49
+ }
50
+ };
51
+ return throttled;
52
+ }
53
+
54
+ export { throttle };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const clsx = require('clsx');
4
+ const tailwindMerge = require('tailwind-merge');
5
+
6
+ function cn(...inputs) {
7
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
8
+ }
9
+
10
+ exports.cn = cn;
@@ -0,0 +1,8 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ function cn(...inputs) {
5
+ return twMerge(clsx(inputs));
6
+ }
7
+
8
+ export { cn };
package/dist/ui.css ADDED
@@ -0,0 +1,131 @@
1
+ @import "tailwindcss";
2
+
3
+ /* Scan UI components for Tailwind classes */
4
+
5
+
6
+
7
+
8
+
9
+ @custom-variant dark (&:is(.dark *));
10
+
11
+ :root {
12
+ --background: oklch(1 0 0);
13
+ --foreground: oklch(0.145 0 0);
14
+ --card: oklch(1 0 0);
15
+ --card-foreground: oklch(0.145 0 0);
16
+ --popover: oklch(1 0 0);
17
+ --popover-foreground: oklch(0.145 0 0);
18
+ --primary: oklch(0.205 0 0);
19
+ --primary-foreground: oklch(0.985 0 0);
20
+ --secondary: oklch(0.97 0 0);
21
+ --secondary-foreground: oklch(0.205 0 0);
22
+ --muted: oklch(0.97 0 0);
23
+ --muted-foreground: oklch(0.556 0 0);
24
+ --accent: oklch(0.97 0 0);
25
+ --accent-foreground: oklch(0.205 0 0);
26
+ --destructive: oklch(0.577 0.245 27.325);
27
+ --destructive-foreground: oklch(0.577 0.245 27.325);
28
+ --border: oklch(0.922 0 0);
29
+ --input: oklch(0.922 0 0);
30
+ --ring: oklch(0.708 0 0);
31
+ --chart-1: oklch(0.646 0.222 41.116);
32
+ --chart-2: oklch(0.6 0.118 184.704);
33
+ --chart-3: oklch(0.398 0.07 227.392);
34
+ --chart-4: oklch(0.828 0.189 84.429);
35
+ --chart-5: oklch(0.769 0.188 70.08);
36
+ --radius: 0.625rem;
37
+ --sidebar: oklch(0.985 0 0);
38
+ --sidebar-foreground: oklch(0.145 0 0);
39
+ --sidebar-primary: oklch(0.205 0 0);
40
+ --sidebar-primary-foreground: oklch(0.985 0 0);
41
+ --sidebar-accent: oklch(0.97 0 0);
42
+ --sidebar-accent-foreground: oklch(0.205 0 0);
43
+ --sidebar-border: oklch(0.922 0 0);
44
+ --sidebar-ring: oklch(0.708 0 0);
45
+ }
46
+
47
+ .dark {
48
+ --background: oklch(0.145 0 0);
49
+ --foreground: oklch(0.985 0 0);
50
+ --card: oklch(0.145 0 0);
51
+ --card-foreground: oklch(0.985 0 0);
52
+ --popover: oklch(0.145 0 0);
53
+ --popover-foreground: oklch(0.985 0 0);
54
+ --primary: oklch(0.985 0 0);
55
+ --primary-foreground: oklch(0.205 0 0);
56
+ --secondary: oklch(0.269 0 0);
57
+ --secondary-foreground: oklch(0.985 0 0);
58
+ --muted: oklch(0.269 0 0);
59
+ --muted-foreground: oklch(0.708 0 0);
60
+ --accent: oklch(0.269 0 0);
61
+ --accent-foreground: oklch(0.985 0 0);
62
+ --destructive: oklch(0.396 0.141 25.723);
63
+ --destructive-foreground: oklch(0.637 0.237 25.331);
64
+ --border: oklch(0.269 0 0);
65
+ --input: oklch(0.269 0 0);
66
+ --ring: oklch(0.556 0 0);
67
+ --chart-1: oklch(0.488 0.243 264.376);
68
+ --chart-2: oklch(0.696 0.17 162.48);
69
+ --chart-3: oklch(0.769 0.188 70.08);
70
+ --chart-4: oklch(0.627 0.265 303.9);
71
+ --chart-5: oklch(0.645 0.246 16.439);
72
+ --sidebar: oklch(0.205 0 0);
73
+ --sidebar-foreground: oklch(0.985 0 0);
74
+ --sidebar-primary: oklch(0.488 0.243 264.376);
75
+ --sidebar-primary-foreground: oklch(0.985 0 0);
76
+ --sidebar-accent: oklch(0.269 0 0);
77
+ --sidebar-accent-foreground: oklch(0.985 0 0);
78
+ --sidebar-border: oklch(0.269 0 0);
79
+ --sidebar-ring: oklch(0.439 0 0);
80
+ }
81
+
82
+ @theme inline {
83
+ --color-background: var(--background);
84
+ --color-foreground: var(--foreground);
85
+ --color-card: var(--card);
86
+ --color-card-foreground: var(--card-foreground);
87
+ --color-popover: var(--popover);
88
+ --color-popover-foreground: var(--popover-foreground);
89
+ --color-primary: var(--primary);
90
+ --color-primary-foreground: var(--primary-foreground);
91
+ --color-secondary: var(--secondary);
92
+ --color-secondary-foreground: var(--secondary-foreground);
93
+ --color-muted: var(--muted);
94
+ --color-muted-foreground: var(--muted-foreground);
95
+ --color-accent: var(--accent);
96
+ --color-accent-foreground: var(--accent-foreground);
97
+ --color-destructive: var(--destructive);
98
+ --color-destructive-foreground: var(--destructive-foreground);
99
+ --color-border: var(--border);
100
+ --color-input: var(--input);
101
+ --color-ring: var(--ring);
102
+ --color-chart-1: var(--chart-1);
103
+ --color-chart-2: var(--chart-2);
104
+ --color-chart-3: var(--chart-3);
105
+ --color-chart-4: var(--chart-4);
106
+ --color-chart-5: var(--chart-5);
107
+ --radius-sm: calc(var(--radius) - 4px);
108
+ --radius-md: calc(var(--radius) - 2px);
109
+ --radius-lg: var(--radius);
110
+ --radius-xl: calc(var(--radius) + 4px);
111
+ --color-sidebar: var(--sidebar);
112
+ --color-sidebar-foreground: var(--sidebar-foreground);
113
+ --color-sidebar-primary: var(--sidebar-primary);
114
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
115
+ --color-sidebar-accent: var(--sidebar-accent);
116
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
117
+ --color-sidebar-border: var(--sidebar-border);
118
+ --color-sidebar-ring: var(--sidebar-ring);
119
+ }
120
+
121
+ @layer base {
122
+ * {
123
+ @apply border-border outline-ring/50;
124
+ }
125
+ body {
126
+ @apply bg-background text-foreground;
127
+ }
128
+ }
129
+
130
+
131
+ @source "./**/*.{mjs,cjs}";