@dxos/react-ui-form 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0
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/lib/browser/index.mjs +731 -573
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +748 -598
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +731 -573
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +4 -4
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +33 -32
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +3 -3
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/RefField.d.ts +7 -18
- package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/factory.d.ts +1 -1
- package/dist/types/src/components/Form/factory.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/Test.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.d.ts +2 -2
- package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts +2 -2
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueryRefOptions.d.ts +23 -0
- package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +1 -0
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +8 -0
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +1 -0
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/refs.d.ts +9 -0
- package/dist/types/src/util/refs.d.ts.map +1 -0
- package/dist/types/src/util/schema.d.ts +3 -0
- package/dist/types/src/util/schema.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -25
- package/src/components/ControlSection/ControlSection.stories.tsx +1 -1
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/Form/ArrayField.tsx +10 -16
- package/src/components/Form/Defaults.tsx +4 -1
- package/src/components/Form/Form.stories.tsx +48 -42
- package/src/components/Form/Form.tsx +4 -4
- package/src/components/Form/FormContent.tsx +49 -22
- package/src/components/Form/FormContext.tsx +3 -1
- package/src/components/Form/Input.tsx +3 -9
- package/src/components/Form/RefField.tsx +147 -101
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +6 -5
- package/src/components/Form/factory.tsx +1 -1
- package/src/components/Form/index.ts +0 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +5 -4
- package/src/components/ViewEditor/ViewEditor.tsx +23 -20
- package/src/components/deprecated/Form.tsx +6 -6
- package/src/hooks/index.ts +3 -1
- package/src/hooks/useForm.ts +4 -3
- package/src/hooks/useQueryRefOptions.ts +53 -0
- package/src/hooks/useRefQueryLookupHandler.ts +41 -0
- package/src/util/index.ts +3 -1
- package/src/util/refs.ts +38 -0
- package/src/util/schema.ts +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/deprecated/FormInput.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,GAAG,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG7D;;GAEG;AACH,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/deprecated/FormInput.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,GAAG,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG7D;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,0BAA0B,eAAe,CAAC,iBAAiB,CAAC,gBAQnG,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,8CAKjC,iBAAiB,CAAC,wBAAwB,CAAC,gBAkC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../src/components/testing.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../src/components/testing.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,eAAO,MAAM,SAAS,GAAI,0BAA0B,eAAe,CAAC,iBAAiB,CAAC,sBAIrF,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,gCAAgC,eAAe,CAAC,iBAAiB,CAAC;IAAE,IAAI,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC,sBAO5G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Schema
|
|
1
|
+
import { type Schema } from 'effect';
|
|
2
2
|
import { type BaseObject } from '@dxos/echo-schema';
|
|
3
3
|
import { type SimpleType, type JsonPath } from '@dxos/effect';
|
|
4
4
|
import { type ValidationError } from '@dxos/schema';
|
|
@@ -29,7 +29,7 @@ export interface FormOptions<T extends BaseObject> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Effect schema (Type literal).
|
|
31
31
|
*/
|
|
32
|
-
schema:
|
|
32
|
+
schema: Schema.Schema<T, any>;
|
|
33
33
|
/**
|
|
34
34
|
* Initial values (which may not pass validation).
|
|
35
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useForm.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useForm.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAA4C,MAAM,cAAc,CAAC;AAGxG,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,UAAU,IAAI;IAK9C,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;IAMvB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxF,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClF,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,UAAU;IAC/C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE9B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAE/C;;;;OAIG;IAEH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,eAAe,EAAE,GAAG,SAAS,CAAC;IAE1D;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IAE5E;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;KAAE,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CAC1F;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,UAAU,EAAE,0EAO3C,WAAW,CAAC,CAAC,CAAC,KAAG,WAAW,CAAC,CAAC,CAoLhC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type TypeAnnotation } from '@dxos/echo-schema';
|
|
2
|
+
import { type DXN } from '@dxos/keys';
|
|
3
|
+
import { type TagPickerItemData } from '@dxos/react-ui-tag-picker';
|
|
4
|
+
import { type MaybePromise } from '@dxos/util';
|
|
5
|
+
export type RefOption = {
|
|
6
|
+
dxn: DXN;
|
|
7
|
+
label?: string;
|
|
8
|
+
};
|
|
9
|
+
export type QueryRefOptions = (type: TypeAnnotation) => MaybePromise<RefOption[]>;
|
|
10
|
+
type UseQueryRefOptionsProps = {
|
|
11
|
+
refTypeInfo: TypeAnnotation | undefined;
|
|
12
|
+
onQueryRefOptions?: QueryRefOptions;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Hook to query reference options based on type information.
|
|
16
|
+
* Used internally within forms to fetch and format reference options for reference fields.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useQueryRefOptions: ({ refTypeInfo, onQueryRefOptions }: UseQueryRefOptionsProps) => {
|
|
19
|
+
options: TagPickerItemData[];
|
|
20
|
+
loading: boolean;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=useQueryRefOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useQueryRefOptions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useQueryRefOptions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;AAElF,KAAK,uBAAuB,GAAG;IAAE,WAAW,EAAE,cAAc,GAAG,SAAS,CAAC;IAAC,iBAAiB,CAAC,EAAE,eAAe,CAAA;CAAE,CAAC;AAEhH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,oCAAoC,uBAAuB;;;CA+B7F,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
2
|
+
import { type QueryRefOptions } from './useQueryRefOptions';
|
|
3
|
+
type UseRefQueryLookupProps = {
|
|
4
|
+
space?: Space;
|
|
5
|
+
};
|
|
6
|
+
export declare const useRefQueryLookupHandler: ({ space }: UseRefQueryLookupProps) => QueryRefOptions;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=useRefQueryLookupHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRefQueryLookupHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useRefQueryLookupHandler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,KAAK,sBAAsB,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEhD,eAAO,MAAM,wBAAwB,GAAI,WAAW,sBAAsB,KAAG,eA0B5E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/util/field.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAe,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/util/field.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAe,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,yBAAyB,UAAU,QAsF7D,CAAC;AAGF,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,kBAAkB,4BAA4B,KAAG,MAAM,EAAE,GAAG,SAmCnG,CAAC;AAGF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,eAGhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../../src/util/formatting.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAe,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEtE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AAGH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../../src/util/formatting.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAe,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEtE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AAGH,eAAO,MAAM,gBAAgB,GAAI,iCAA6C,gBAAgB,KAAG,MAqFhG,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,iCAA6C,gBAAgB,KAAG,MA8DhG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/util/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/util/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SchemaAST } from 'effect';
|
|
2
|
+
import { type SchemaProperty } from '@dxos/schema';
|
|
3
|
+
type RefProps = {
|
|
4
|
+
ast: SchemaAST.AST;
|
|
5
|
+
isArray: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const getRefProps: (property: SchemaProperty<any>) => RefProps | undefined;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../../src/util/refs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIxC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAInD,KAAK,QAAQ,GAAG;IACd,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,UAAU,cAAc,CAAC,GAAG,CAAC,KAAG,QAAQ,GAAG,SAoBtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/util/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAInC,eAAO,MAAM,oBAAoB,GAAI,KAAK,SAAS,CAAC,GAAG,8BAKtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-form",
|
|
3
|
-
"version": "0.8.2-main.
|
|
3
|
+
"version": "0.8.2-main.fbd8ed0",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -28,46 +28,47 @@
|
|
|
28
28
|
"@radix-ui/react-context": "1.1.1",
|
|
29
29
|
"date-fns": "^3.3.1",
|
|
30
30
|
"jsonpath": "^1.1.1",
|
|
31
|
-
"@dxos/async": "0.8.2-main.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/echo-
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/keys": "0.8.2-main.
|
|
38
|
-
"@dxos/live-object": "0.8.2-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/react-
|
|
42
|
-
"@dxos/react-ui-
|
|
43
|
-
"@dxos/react-ui-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
31
|
+
"@dxos/async": "0.8.2-main.fbd8ed0",
|
|
32
|
+
"@dxos/debug": "0.8.2-main.fbd8ed0",
|
|
33
|
+
"@dxos/echo-db": "0.8.2-main.fbd8ed0",
|
|
34
|
+
"@dxos/echo-schema": "0.8.2-main.fbd8ed0",
|
|
35
|
+
"@dxos/effect": "0.8.2-main.fbd8ed0",
|
|
36
|
+
"@dxos/invariant": "0.8.2-main.fbd8ed0",
|
|
37
|
+
"@dxos/keys": "0.8.2-main.fbd8ed0",
|
|
38
|
+
"@dxos/live-object": "0.8.2-main.fbd8ed0",
|
|
39
|
+
"@dxos/log": "0.8.2-main.fbd8ed0",
|
|
40
|
+
"@dxos/react-client": "0.8.2-main.fbd8ed0",
|
|
41
|
+
"@dxos/react-ui-list": "0.8.2-main.fbd8ed0",
|
|
42
|
+
"@dxos/react-ui-pickers": "0.8.2-main.fbd8ed0",
|
|
43
|
+
"@dxos/react-ui-tag-picker": "0.8.2-main.fbd8ed0",
|
|
44
|
+
"@dxos/react-ui-types": "0.8.2-main.fbd8ed0",
|
|
45
|
+
"@dxos/schema": "0.8.2-main.fbd8ed0",
|
|
46
|
+
"@dxos/util": "0.8.2-main.fbd8ed0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@phosphor-icons/react": "^2.1.5",
|
|
49
50
|
"@types/jsonpath": "^0.2.4",
|
|
50
51
|
"@types/react": "~18.2.0",
|
|
51
52
|
"@types/react-dom": "~18.2.0",
|
|
52
|
-
"effect": "3.
|
|
53
|
+
"effect": "3.14.21",
|
|
53
54
|
"fast-check": "^3.19.0",
|
|
54
55
|
"react": "~18.2.0",
|
|
55
56
|
"react-dom": "~18.2.0",
|
|
56
57
|
"vite": "5.4.7",
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/react-ui
|
|
60
|
-
"@dxos/react-ui": "0.8.2-main.
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
58
|
+
"@dxos/echo-signals": "0.8.2-main.fbd8ed0",
|
|
59
|
+
"@dxos/random": "0.8.2-main.fbd8ed0",
|
|
60
|
+
"@dxos/react-ui": "0.8.2-main.fbd8ed0",
|
|
61
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.2-main.fbd8ed0",
|
|
62
|
+
"@dxos/react-ui-theme": "0.8.2-main.fbd8ed0",
|
|
63
|
+
"@dxos/storybook-utils": "0.8.2-main.fbd8ed0"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"@phosphor-icons/react": "^2.1.5",
|
|
66
67
|
"effect": "3.13.3",
|
|
67
68
|
"react": "~18.2.0",
|
|
68
69
|
"react-dom": "~18.2.0",
|
|
69
|
-
"@dxos/react-ui": "0.8.2-main.
|
|
70
|
-
"@dxos/react-ui
|
|
70
|
+
"@dxos/react-ui-theme": "0.8.2-main.fbd8ed0",
|
|
71
|
+
"@dxos/react-ui": "0.8.2-main.fbd8ed0"
|
|
71
72
|
},
|
|
72
73
|
"publishConfig": {
|
|
73
74
|
"access": "public"
|
|
@@ -14,7 +14,7 @@ import translations from '../../translations';
|
|
|
14
14
|
const meta: Meta<ControlSectionProps> = {
|
|
15
15
|
title: 'ui/react-ui-form/ControlSection',
|
|
16
16
|
component: ControlSection,
|
|
17
|
-
decorators: [withLayout(
|
|
17
|
+
decorators: [withLayout(), withTheme],
|
|
18
18
|
parameters: {
|
|
19
19
|
translations,
|
|
20
20
|
},
|
|
@@ -37,7 +37,7 @@ const meta: Meta<StoryProps> = {
|
|
|
37
37
|
title: 'ui/react-ui-form/FieldEditor',
|
|
38
38
|
component: FieldEditor,
|
|
39
39
|
render: DefaultStory,
|
|
40
|
-
decorators: [withLayout({ fullscreen: true
|
|
40
|
+
decorators: [withLayout({ fullscreen: true }), withTheme],
|
|
41
41
|
parameters: {
|
|
42
42
|
translations,
|
|
43
43
|
},
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { pipe } from 'effect';
|
|
5
|
+
import { SchemaAST, pipe } from 'effect';
|
|
6
6
|
import { capitalize } from 'effect/String';
|
|
7
|
-
import React, { useCallback
|
|
7
|
+
import React, { useCallback } from 'react';
|
|
8
8
|
|
|
9
|
-
import { AST } from '@dxos/echo-schema';
|
|
10
9
|
import { findNode, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from '@dxos/effect';
|
|
11
10
|
import { invariant } from '@dxos/invariant';
|
|
12
11
|
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
@@ -18,6 +17,7 @@ import { FormField } from './FormContent';
|
|
|
18
17
|
import { useFormValues, type FormInputStateProps } from './FormContext';
|
|
19
18
|
import { InputHeader, type InputComponent } from './Input';
|
|
20
19
|
import { translationKey } from '../../translations';
|
|
20
|
+
import { findArrayElementType } from '../../util';
|
|
21
21
|
|
|
22
22
|
const padding = 'px-2';
|
|
23
23
|
|
|
@@ -39,12 +39,11 @@ export const ArrayField = ({ property, readonly, path, inputProps, Custom, looku
|
|
|
39
39
|
invariant(Array.isArray(values), `Values at path ${path?.join('.')} must be an array.`);
|
|
40
40
|
const label = title ?? pipe(name, capitalize);
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
const elementType = (tupleType as AST.TupleType | undefined)?.rest[0]?.type;
|
|
42
|
+
const elementType = findArrayElementType(ast);
|
|
44
43
|
|
|
45
|
-
const getDefaultObjectValue = (typeNode:
|
|
44
|
+
const getDefaultObjectValue = (typeNode: SchemaAST.AST): any => {
|
|
46
45
|
const baseNode = findNode(typeNode, isDiscriminatedUnion);
|
|
47
|
-
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode(typeNode,
|
|
46
|
+
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode(typeNode, SchemaAST.isTypeLiteral);
|
|
48
47
|
if (!typeLiteral) {
|
|
49
48
|
return {};
|
|
50
49
|
}
|
|
@@ -52,17 +51,12 @@ export const ArrayField = ({ property, readonly, path, inputProps, Custom, looku
|
|
|
52
51
|
return Object.fromEntries(getSchemaProperties(typeLiteral, {}).map((prop) => [prop.name, prop.defaultValue]));
|
|
53
52
|
};
|
|
54
53
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
return getDefaultObjectValue(elementType);
|
|
58
|
-
} else {
|
|
59
|
-
return SimpleType.getDefaultValue(type);
|
|
60
|
-
}
|
|
61
|
-
}, [type, elementType]);
|
|
54
|
+
const getDefaultValue = () =>
|
|
55
|
+
type === 'object' && elementType ? getDefaultObjectValue(elementType) : SimpleType.getDefaultValue(type);
|
|
62
56
|
|
|
63
57
|
const handleAdd = useCallback(() => {
|
|
64
|
-
inputProps.onValueChange(type, [...values,
|
|
65
|
-
}, [type, elementType, inputProps,
|
|
58
|
+
inputProps.onValueChange(type, [...values, getDefaultValue()]);
|
|
59
|
+
}, [type, elementType, inputProps, values]);
|
|
66
60
|
|
|
67
61
|
const handleRemove = useCallback(
|
|
68
62
|
(index: number) => {
|
|
@@ -107,6 +107,9 @@ export const SelectInput = ({
|
|
|
107
107
|
}: SelectInputOptions) => {
|
|
108
108
|
const { status, error } = getStatus();
|
|
109
109
|
|
|
110
|
+
const value = getValue() as string | undefined;
|
|
111
|
+
const handleValueChange = useCallback((value: string | number) => onValueChange(type, value), [type, onValueChange]);
|
|
112
|
+
|
|
110
113
|
return (
|
|
111
114
|
<Input.Root validationValence={status}>
|
|
112
115
|
{!inputOnly && (
|
|
@@ -114,7 +117,7 @@ export const SelectInput = ({
|
|
|
114
117
|
<Input.Label>{label}</Input.Label>
|
|
115
118
|
</InputHeader>
|
|
116
119
|
)}
|
|
117
|
-
<Select.Root value={
|
|
120
|
+
<Select.Root value={value} onValueChange={handleValueChange}>
|
|
118
121
|
{/* TODO(burdon): Placeholder not working? */}
|
|
119
122
|
<Select.TriggerButton classNames='is-full' disabled={disabled} placeholder={placeholder} />
|
|
120
123
|
<Select.Portal>
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
8
|
+
import { Schema, SchemaAST } from 'effect';
|
|
8
9
|
import React, { useCallback, useState } from 'react';
|
|
9
10
|
|
|
10
11
|
import { ContactType } from '@dxos/client/testing';
|
|
11
|
-
import {
|
|
12
|
+
import { type BaseObject, Expando, Format, getDXN, Ref, type TypeAnnotation } from '@dxos/echo-schema';
|
|
12
13
|
import { live } from '@dxos/live-object';
|
|
13
14
|
import { Testing } from '@dxos/schema/testing';
|
|
14
15
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
@@ -18,25 +19,27 @@ import { Form, type FormProps } from './Form';
|
|
|
18
19
|
import translations from '../../translations';
|
|
19
20
|
import { TestLayout, TestPanel } from '../testing';
|
|
20
21
|
|
|
21
|
-
const AddressSchema =
|
|
22
|
-
street:
|
|
23
|
-
city:
|
|
24
|
-
zip:
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const AddressSchema = Schema.Struct({
|
|
23
|
+
street: Schema.optional(Schema.String.annotations({ [SchemaAST.TitleAnnotationId]: 'Street' })),
|
|
24
|
+
city: Schema.optional(Schema.String.annotations({ [SchemaAST.TitleAnnotationId]: 'City' })),
|
|
25
|
+
zip: Schema.optional(
|
|
26
|
+
Schema.String.pipe(Schema.pattern(/^\d{5}(-\d{4})?$/)).annotations({ [SchemaAST.TitleAnnotationId]: 'ZIP' }),
|
|
27
|
+
),
|
|
28
|
+
location: Schema.optional(Format.GeoPoint.annotations({ [SchemaAST.TitleAnnotationId]: 'Location' })),
|
|
29
|
+
}).annotations({ [SchemaAST.TitleAnnotationId]: 'Address' });
|
|
27
30
|
|
|
28
31
|
// TODO(burdon): Translations?
|
|
29
|
-
const TestSchema =
|
|
30
|
-
name:
|
|
31
|
-
active:
|
|
32
|
-
rank:
|
|
33
|
-
website:
|
|
34
|
-
address:
|
|
35
|
-
}).pipe(
|
|
32
|
+
const TestSchema = Schema.Struct({
|
|
33
|
+
name: Schema.optional(Schema.String.annotations({ [SchemaAST.TitleAnnotationId]: 'Name' })),
|
|
34
|
+
active: Schema.optional(Schema.Boolean.annotations({ [SchemaAST.TitleAnnotationId]: 'Active' })),
|
|
35
|
+
rank: Schema.optional(Schema.Number.annotations({ [SchemaAST.TitleAnnotationId]: 'Rank' })),
|
|
36
|
+
website: Schema.optional(Format.URL.annotations({ [SchemaAST.TitleAnnotationId]: 'Website' })),
|
|
37
|
+
address: Schema.optional(AddressSchema),
|
|
38
|
+
}).pipe(Schema.mutable);
|
|
36
39
|
|
|
37
|
-
type TestType =
|
|
40
|
+
type TestType = Schema.Schema.Type<typeof TestSchema>;
|
|
38
41
|
|
|
39
|
-
type StoryProps<T extends BaseObject> = { schema:
|
|
42
|
+
type StoryProps<T extends BaseObject> = { schema: Schema.Schema<T> } & FormProps<T>;
|
|
40
43
|
|
|
41
44
|
const DefaultStory = <T extends BaseObject>({ schema, values: initialValues, ...props }: StoryProps<T>) => {
|
|
42
45
|
const [values, setValues] = useState(initialValues);
|
|
@@ -57,7 +60,7 @@ const meta: Meta<StoryProps<any>> = {
|
|
|
57
60
|
title: 'ui/react-ui-form/Form',
|
|
58
61
|
component: Form,
|
|
59
62
|
render: DefaultStory,
|
|
60
|
-
decorators: [withLayout({ fullscreen: true
|
|
63
|
+
decorators: [withLayout({ fullscreen: true }), withTheme],
|
|
61
64
|
parameters: {
|
|
62
65
|
translations,
|
|
63
66
|
},
|
|
@@ -117,22 +120,24 @@ export const OrganizationAutoSave: Story<Testing.Organization> = {
|
|
|
117
120
|
// TODO(burdon): Move into separate storybook and use test types.
|
|
118
121
|
//
|
|
119
122
|
|
|
120
|
-
const ShapeSchema =
|
|
121
|
-
shape:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
type:
|
|
125
|
-
radius:
|
|
123
|
+
const ShapeSchema = Schema.Struct({
|
|
124
|
+
shape: Schema.optional(
|
|
125
|
+
Schema.Union(
|
|
126
|
+
Schema.Struct({
|
|
127
|
+
type: Schema.Literal('circle').annotations({ [SchemaAST.TitleAnnotationId]: 'Type' }),
|
|
128
|
+
radius: Schema.optional(Schema.Number.annotations({ [SchemaAST.TitleAnnotationId]: 'Radius' })),
|
|
126
129
|
}),
|
|
127
|
-
|
|
128
|
-
type:
|
|
129
|
-
size:
|
|
130
|
+
Schema.Struct({
|
|
131
|
+
type: Schema.Literal('square').annotations({ [SchemaAST.TitleAnnotationId]: 'Type' }),
|
|
132
|
+
size: Schema.optional(
|
|
133
|
+
Schema.Number.pipe(Schema.nonNegative()).annotations({ [SchemaAST.TitleAnnotationId]: 'Size' }),
|
|
134
|
+
),
|
|
130
135
|
}),
|
|
131
|
-
).annotations({ [
|
|
136
|
+
).annotations({ [SchemaAST.TitleAnnotationId]: 'Shape' }),
|
|
132
137
|
),
|
|
133
|
-
}).pipe(
|
|
138
|
+
}).pipe(Schema.mutable);
|
|
134
139
|
|
|
135
|
-
type ShapeType =
|
|
140
|
+
type ShapeType = Schema.Schema.Type<typeof ShapeSchema>;
|
|
136
141
|
|
|
137
142
|
type DiscriminatedUnionStoryProps = FormProps<ShapeType>;
|
|
138
143
|
|
|
@@ -178,12 +183,12 @@ export const DiscriminatedShape: StoryObj<DiscriminatedUnionStoryProps> = {
|
|
|
178
183
|
},
|
|
179
184
|
};
|
|
180
185
|
|
|
181
|
-
const ArraysSchema =
|
|
182
|
-
names:
|
|
183
|
-
addresses:
|
|
184
|
-
}).pipe(
|
|
186
|
+
const ArraysSchema = Schema.Struct({
|
|
187
|
+
names: Schema.Array(Schema.String.pipe(Schema.nonEmptyString())),
|
|
188
|
+
addresses: Schema.Array(AddressSchema),
|
|
189
|
+
}).pipe(Schema.mutable);
|
|
185
190
|
|
|
186
|
-
type ArraysType =
|
|
191
|
+
type ArraysType = Schema.Schema.Type<typeof ArraysSchema>;
|
|
187
192
|
|
|
188
193
|
const ArraysStory = ({ values: initialValues }: FormProps<ArraysType>) => {
|
|
189
194
|
const [values, setValues] = useState(initialValues);
|
|
@@ -210,13 +215,13 @@ export const Arrays: StoryObj<FormProps<ArraysType>> = {
|
|
|
210
215
|
},
|
|
211
216
|
};
|
|
212
217
|
|
|
213
|
-
const ColorSchema =
|
|
214
|
-
color:
|
|
215
|
-
[
|
|
218
|
+
const ColorSchema = Schema.Struct({
|
|
219
|
+
color: Schema.Union(Schema.Literal('red'), Schema.Literal('green'), Schema.Literal('blue')).annotations({
|
|
220
|
+
[SchemaAST.TitleAnnotationId]: 'Color',
|
|
216
221
|
}),
|
|
217
|
-
}).pipe(
|
|
222
|
+
}).pipe(Schema.mutable);
|
|
218
223
|
|
|
219
|
-
type ColorType =
|
|
224
|
+
type ColorType = Schema.Schema.Type<typeof ColorSchema>;
|
|
220
225
|
|
|
221
226
|
const EnumStory = ({ values: initialValues }: FormProps<ColorType>) => {
|
|
222
227
|
const [values, setValues] = useState(initialValues);
|
|
@@ -242,10 +247,11 @@ export const Enum: StoryObj<FormProps<ColorType>> = {
|
|
|
242
247
|
},
|
|
243
248
|
};
|
|
244
249
|
|
|
245
|
-
const RefSchema =
|
|
250
|
+
const RefSchema = Schema.Struct({
|
|
246
251
|
contact: Ref(ContactType).annotations({ title: 'Contact Reference' }),
|
|
247
|
-
optionalContact:
|
|
248
|
-
|
|
252
|
+
optionalContact: Schema.optional(Ref(ContactType).annotations({ title: 'Optional Contact Reference' })),
|
|
253
|
+
refArray: Schema.optional(Schema.Array(Ref(ContactType))),
|
|
254
|
+
unknownExpando: Schema.optional(Ref(Expando).annotations({ title: 'Optional Ref to an Expando (DXN Input)' })),
|
|
249
255
|
});
|
|
250
256
|
|
|
251
257
|
const RefStory = ({ values: initialValues }: FormProps<any>) => {
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Schema } from 'effect';
|
|
5
6
|
import React, { type ReactElement, useEffect, useMemo, useRef } from 'react';
|
|
6
7
|
|
|
7
|
-
import { type BaseObject, type
|
|
8
|
+
import { type BaseObject, type PropertyKey } from '@dxos/echo-schema';
|
|
8
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
10
|
import { mx } from '@dxos/react-ui-theme';
|
|
10
11
|
import { type SchemaProperty } from '@dxos/schema';
|
|
@@ -13,14 +14,13 @@ import { FormActions } from './FormActions';
|
|
|
13
14
|
import { FormFields } from './FormContent';
|
|
14
15
|
import { FormProvider } from './FormContext';
|
|
15
16
|
import { type InputProps, type InputComponent } from './Input';
|
|
16
|
-
import { type QueryRefOptions } from '
|
|
17
|
-
import { type FormOptions } from '../../hooks';
|
|
17
|
+
import { type FormOptions, type QueryRefOptions } from '../../hooks';
|
|
18
18
|
|
|
19
19
|
export type PropsFilter<T extends BaseObject> = (props: SchemaProperty<T>[]) => SchemaProperty<T>[];
|
|
20
20
|
|
|
21
21
|
export type ComponentLookup = (args: {
|
|
22
22
|
prop: string;
|
|
23
|
-
schema:
|
|
23
|
+
schema: Schema.Schema<any>;
|
|
24
24
|
inputProps: InputProps;
|
|
25
25
|
}) => ReactElement | undefined;
|
|
26
26
|
|