autoforma 1.0.0 → 1.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.
- package/dist/index.cjs.js +70 -0
- package/dist/index.es.js +13532 -0
- package/dist/src/components/AutoForm.d.ts +18 -0
- package/dist/src/components/FieldRender.d.ts +16 -0
- package/dist/src/components/fields/ArrayField.d.ts +13 -0
- package/dist/src/components/fields/CheckField.d.ts +7 -0
- package/dist/src/components/fields/DateField.d.ts +6 -0
- package/dist/src/components/fields/DateTimeField.d.ts +6 -0
- package/dist/src/components/fields/NumberField.d.ts +6 -0
- package/dist/src/components/fields/ObjectField.d.ts +9 -0
- package/dist/src/components/fields/SelectField.d.ts +10 -0
- package/dist/src/components/fields/TextAreaField.d.ts +6 -0
- package/dist/src/components/fields/TextField.d.ts +6 -0
- package/dist/src/components/fields/TimeField.d.ts +6 -0
- package/{src/index.ts → dist/src/index.d.ts} +2 -3
- package/dist/src/stories/AutoForm.stories.d.ts +9 -0
- package/dist/src/stories/Fields.stories.d.ts +12 -0
- package/dist/src/theme.d.ts +141 -0
- package/dist/src/types/custom-render.d.ts +11 -0
- package/dist/src/types/field.d.ts +30 -0
- package/dist/src/types/form.d.ts +7 -0
- package/{test-utils/index.ts → dist/test-utils/index.d.ts} +1 -2
- package/dist/test-utils/render.d.ts +1 -0
- package/package.json +9 -3
- package/.github/workflows/npm_test.yml +0 -27
- package/.nvmrc +0 -1
- package/.prettierrc.mjs +0 -35
- package/.storybook/main.ts +0 -17
- package/.storybook/preview.tsx +0 -18
- package/.storybook/vitest.setup.ts +0 -9
- package/.stylelintignore +0 -1
- package/.stylelintrc.json +0 -28
- package/.yarn/releases/yarn-4.9.1.cjs +0 -948
- package/.yarnrc.yml +0 -3
- package/eslint.config.js +0 -11
- package/index.html +0 -16
- package/postcss.config.cjs +0 -14
- package/src/favicon.svg +0 -1
- package/src/stories/AutoForm.stories.tsx +0 -473
- package/src/stories/Fields.stories.tsx +0 -190
- package/src/theme.ts +0 -5
- package/src/vite-env.d.ts +0 -1
- package/storybook-static/assets/AutoForm-CEr4m2za.js +0 -53
- package/storybook-static/assets/AutoForm.stories-CtOmRKOV.js +0 -164
- package/storybook-static/assets/Color-YHDXOIA2-pc5-Ao7n.js +0 -1
- package/storybook-static/assets/DocsRenderer-CFRXHY34-D-_1VvMG.js +0 -575
- package/storybook-static/assets/Fields.stories-CoRkpMbJ.js +0 -29
- package/storybook-static/assets/chunk-XP5HYGXS-BpfKkqn7.js +0 -1
- package/storybook-static/assets/entry-preview-CkHoqRUh.js +0 -2
- package/storybook-static/assets/entry-preview-docs-hFR7sEJd.js +0 -46
- package/storybook-static/assets/get-contrast-color-Db6nT3bs.js +0 -1
- package/storybook-static/assets/iframe-CzpwBD2i.js +0 -211
- package/storybook-static/assets/index-B8rYRX2K.js +0 -1
- package/storybook-static/assets/index-BQQLSK9g.js +0 -1
- package/storybook-static/assets/index-CXQShRbs.js +0 -8
- package/storybook-static/assets/index-D4lIrffr.js +0 -9
- package/storybook-static/assets/index-Domkg0jQ.js +0 -240
- package/storybook-static/assets/index-DrFu-skq.js +0 -6
- package/storybook-static/assets/index-DsJinFGm.js +0 -9
- package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +0 -9
- package/storybook-static/assets/preview-B8lJiyuQ.js +0 -34
- package/storybook-static/assets/preview-BBWR9nbA.js +0 -1
- package/storybook-static/assets/preview-BOfrPh1e.js +0 -2
- package/storybook-static/assets/preview-BWzBA1C2.js +0 -396
- package/storybook-static/assets/preview-C2Qr78FS.js +0 -4
- package/storybook-static/assets/preview-CvbIS5ZJ.js +0 -1
- package/storybook-static/assets/preview-DD_OYowb.js +0 -1
- package/storybook-static/assets/preview-DGUiP6tS.js +0 -7
- package/storybook-static/assets/preview-DioFdWiE.css +0 -1
- package/storybook-static/assets/preview-Dyg8NwXV.js +0 -1
- package/storybook-static/assets/react-18-Dhjvimrl.js +0 -25
- package/storybook-static/assets/test-utils--_O2wM1y.js +0 -9
- package/storybook-static/favicon.svg +0 -1
- package/storybook-static/iframe.html +0 -666
- package/storybook-static/index.html +0 -181
- package/storybook-static/index.json +0 -1
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +0 -1
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +0 -331
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +0 -51
- package/storybook-static/sb-addons/docs-11/manager-bundle.js +0 -242
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js +0 -12
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +0 -402
- package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/onboarding-8/manager-bundle.js +0 -127
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +0 -3
- package/storybook-static/sb-addons/storybook-experimental-addon-test-10/manager-bundle.js +0 -223
- package/storybook-static/sb-common-assets/favicon.svg +0 -1
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +0 -1051
- package/storybook-static/sb-manager/globals-runtime.js +0 -41591
- package/storybook-static/sb-manager/globals.js +0 -48
- package/storybook-static/sb-manager/runtime.js +0 -12048
- package/test-utils/render.tsx +0 -11
- package/text +0 -64
- package/tsconfig.json +0 -25
- package/vite.config.mjs +0 -19
- package/vitest.setup.mjs +0 -29
- package/vitest.shims.d.ts +0 -1
- package/vitest.workspace.js +0 -30
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { Button, Grid, Group } from '@mantine/core';
|
|
3
|
-
import AutoForm from '@/components/AutoForm';
|
|
4
|
-
import { FieldSchema } from '@/types/field';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ------------------------------
|
|
8
|
-
// Schema Definitions
|
|
9
|
-
// ------------------------------
|
|
10
|
-
const textFieldSchema: FieldSchema[] = [
|
|
11
|
-
{
|
|
12
|
-
type: 'text',
|
|
13
|
-
name: 'firstName',
|
|
14
|
-
label: 'First Name',
|
|
15
|
-
initialValue: 'John',
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const numberFieldSchema: FieldSchema[] = [
|
|
20
|
-
{
|
|
21
|
-
type: 'number',
|
|
22
|
-
name: 'age',
|
|
23
|
-
label: 'Age',
|
|
24
|
-
initialValue: 30,
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
const selectFieldSchema: FieldSchema[] = [
|
|
29
|
-
{
|
|
30
|
-
type: 'select',
|
|
31
|
-
name: 'gender',
|
|
32
|
-
label: 'Gender',
|
|
33
|
-
data: [
|
|
34
|
-
{ label: 'Male', value: 'male' },
|
|
35
|
-
{ label: 'Female', value: 'female' },
|
|
36
|
-
],
|
|
37
|
-
initialValue: 'male',
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const checkFieldSchema: FieldSchema[] = [
|
|
42
|
-
{
|
|
43
|
-
type: 'check',
|
|
44
|
-
name: 'enabled',
|
|
45
|
-
label: 'Enabled',
|
|
46
|
-
initialValue: true,
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
const dateFieldSchema: FieldSchema[] = [
|
|
51
|
-
{
|
|
52
|
-
type: 'date',
|
|
53
|
-
name: 'birthDate',
|
|
54
|
-
label: 'Birth Date',
|
|
55
|
-
initialValue: new Date(),
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
const arrayFieldSchema: FieldSchema[] = [
|
|
60
|
-
{
|
|
61
|
-
type: 'array',
|
|
62
|
-
name: 'tags',
|
|
63
|
-
label: 'Tags',
|
|
64
|
-
fields: [
|
|
65
|
-
{
|
|
66
|
-
type: 'text',
|
|
67
|
-
name: 'tag',
|
|
68
|
-
label: 'Tag',
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
const objectFieldSchema: FieldSchema[] = [
|
|
75
|
-
{
|
|
76
|
-
type: 'object',
|
|
77
|
-
name: 'address',
|
|
78
|
-
label: 'Address',
|
|
79
|
-
fields: [
|
|
80
|
-
{
|
|
81
|
-
type: 'text',
|
|
82
|
-
name: 'street',
|
|
83
|
-
label: 'Street',
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
type: 'text',
|
|
87
|
-
name: 'city',
|
|
88
|
-
label: 'City',
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
// ------------------------------
|
|
95
|
-
// Storybook Meta
|
|
96
|
-
// ------------------------------
|
|
97
|
-
|
|
98
|
-
const meta: Meta<typeof AutoForm> = {
|
|
99
|
-
title: 'components/Fields',
|
|
100
|
-
component: AutoForm,
|
|
101
|
-
tags: ['autodocs'],
|
|
102
|
-
args: {
|
|
103
|
-
onSubmit: (values) => alert(JSON.stringify(values, null, 2)),
|
|
104
|
-
container: (form, onSubmit, readOnly) => (
|
|
105
|
-
<>
|
|
106
|
-
<Grid>{form}</Grid>
|
|
107
|
-
{!readOnly && (
|
|
108
|
-
<Group justify="flex-end">
|
|
109
|
-
<Button onClick={onSubmit}>Submit</Button>
|
|
110
|
-
</Group>
|
|
111
|
-
)}
|
|
112
|
-
</>
|
|
113
|
-
),
|
|
114
|
-
fieldContainer: (field, fieldSchema) => (
|
|
115
|
-
<Grid.Col span={{ base: 12, md: fieldSchema.type === 'object' ? 12 : 6 }}>{field}</Grid.Col>
|
|
116
|
-
),
|
|
117
|
-
},
|
|
118
|
-
argTypes: {
|
|
119
|
-
onSubmit: {
|
|
120
|
-
table: {
|
|
121
|
-
disable: true,
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
container: {
|
|
125
|
-
table: {
|
|
126
|
-
disable: true,
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
fieldContainer: {
|
|
130
|
-
table: {
|
|
131
|
-
disable: true,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
schema: {
|
|
135
|
-
description:
|
|
136
|
-
'Array of field definitions used to render the form. Each item defines one input field.',
|
|
137
|
-
control: false,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export default meta;
|
|
143
|
-
|
|
144
|
-
// ------------------------------
|
|
145
|
-
// Stories
|
|
146
|
-
// ------------------------------
|
|
147
|
-
|
|
148
|
-
type Story = StoryObj<typeof AutoForm>;
|
|
149
|
-
|
|
150
|
-
export const TextField: Story = {
|
|
151
|
-
args: {
|
|
152
|
-
schema: textFieldSchema,
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export const NumberField: Story = {
|
|
157
|
-
args: {
|
|
158
|
-
schema: numberFieldSchema,
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export const SelectField: Story = {
|
|
163
|
-
args: {
|
|
164
|
-
schema: selectFieldSchema,
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export const CheckField: Story = {
|
|
169
|
-
args: {
|
|
170
|
-
schema: checkFieldSchema,
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export const DateField: Story = {
|
|
175
|
-
args: {
|
|
176
|
-
schema: dateFieldSchema,
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export const ArrayField: Story = {
|
|
181
|
-
args: {
|
|
182
|
-
schema: arrayFieldSchema,
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export const ObjectField: Story = {
|
|
187
|
-
args: {
|
|
188
|
-
schema: objectFieldSchema,
|
|
189
|
-
},
|
|
190
|
-
};
|
package/src/theme.ts
DELETED
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|