@strictly/react-form 0.0.4 → 0.0.5
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/.out/core/mobx/field_adapter_builder.d.ts +1 -1
- package/.out/core/mobx/field_adapter_builder.js +1 -2
- package/.out/mantine/create_list.d.ts +5 -4
- package/.out/mantine/create_list.js +4 -2
- package/.out/mantine/hooks.d.ts +2 -1
- package/.out/mantine/specs/list_hooks.stories.js +6 -6
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-release$colon$exports.log +1 -1
- package/core/mobx/field_adapter_builder.ts +3 -4
- package/dist/index.cjs +8 -18
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +8 -18
- package/mantine/create_list.tsx +10 -4
- package/mantine/hooks.tsx +3 -2
- package/mantine/specs/__snapshots__/list_hooks.tests.tsx.snap +56 -8
- package/mantine/specs/list_hooks.stories.tsx +16 -6
- package/package.json +1 -1
- package/.out/field_converters/list_converter.d.ts +0 -2
- package/.out/field_converters/list_converter.js +0 -13
- package/field_converters/list_converter.ts +0 -20
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,12 +7,12 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Target: esnext
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m43.08 KB[39m
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 117ms
|
|
12
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m46.78 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 117ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m34.
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m34.
|
|
18
|
-
Done in
|
|
15
|
+
[32mDTS[39m ⚡️ Build success in 9983ms
|
|
16
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m34.96 KB[39m
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m34.96 KB[39m
|
|
18
|
+
Done in 11.02s.
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
annotatedIdentityConverter,
|
|
7
7
|
unreliableIdentityConverter,
|
|
8
8
|
} from 'field_converters/identity_converter'
|
|
9
|
-
import { listConverter } from 'field_converters/list_converter'
|
|
10
9
|
import { MaybeIdentityConverter } from 'field_converters/maybe_identity_converter'
|
|
11
10
|
import { prototypingFieldValueFactory } from 'field_value_factories/prototyping_field_value_factory'
|
|
12
11
|
import {
|
|
@@ -266,12 +265,12 @@ export function identityAdapter<
|
|
|
266
265
|
|
|
267
266
|
export function listAdapter<
|
|
268
267
|
E,
|
|
269
|
-
K extends string,
|
|
270
268
|
ValuePath extends string,
|
|
271
269
|
Context,
|
|
272
270
|
>() {
|
|
273
|
-
return new FieldAdapterBuilder<readonly E[], readonly
|
|
274
|
-
|
|
271
|
+
return new FieldAdapterBuilder<readonly E[], readonly E[], never, ValuePath, Context>(
|
|
272
|
+
annotatedIdentityConverter<readonly E[], ValuePath, Context>(false),
|
|
275
273
|
prototypingFieldValueFactory<readonly E[], ValuePath, Context>([]),
|
|
274
|
+
unreliableIdentityConverter<readonly E[], ValuePath, Context>(),
|
|
276
275
|
)
|
|
277
276
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -139,20 +139,6 @@ function unreliableIdentityConverter() {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
// field_converters/list_converter.ts
|
|
143
|
-
function listConverter() {
|
|
144
|
-
return function(from, valuePath) {
|
|
145
|
-
const value = from.map(function(_v, i) {
|
|
146
|
-
return `${valuePath}.${i}`;
|
|
147
|
-
});
|
|
148
|
-
return {
|
|
149
|
-
value,
|
|
150
|
-
required: false,
|
|
151
|
-
readonly: false
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
142
|
// field_converters/maybe_identity_converter.ts
|
|
157
143
|
var MaybeIdentityConverter = class {
|
|
158
144
|
constructor(converter, isFrom) {
|
|
@@ -241,8 +227,9 @@ function identityAdapter(prototype, required) {
|
|
|
241
227
|
}
|
|
242
228
|
function listAdapter() {
|
|
243
229
|
return new FieldAdapterBuilder(
|
|
244
|
-
|
|
245
|
-
prototypingFieldValueFactory([])
|
|
230
|
+
annotatedIdentityConverter(false),
|
|
231
|
+
prototypingFieldValueFactory([]),
|
|
232
|
+
unreliableIdentityConverter()
|
|
246
233
|
);
|
|
247
234
|
}
|
|
248
235
|
|
|
@@ -1210,17 +1197,20 @@ function createList(valuePath, List) {
|
|
|
1210
1197
|
const propSource = () => {
|
|
1211
1198
|
const values = [...this.fields[valuePath].value];
|
|
1212
1199
|
return {
|
|
1213
|
-
values
|
|
1200
|
+
values,
|
|
1201
|
+
listPath: valuePath
|
|
1214
1202
|
};
|
|
1215
1203
|
};
|
|
1216
1204
|
return createUnsafePartialObserverComponent(List, propSource);
|
|
1217
1205
|
}
|
|
1218
1206
|
function DefaultList({
|
|
1219
1207
|
values,
|
|
1208
|
+
listPath,
|
|
1220
1209
|
children
|
|
1221
1210
|
}) {
|
|
1222
1211
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: values.map(function(value, index) {
|
|
1223
|
-
|
|
1212
|
+
const valuePath = `${listPath}.${index}`;
|
|
1213
|
+
return children(valuePath, value, index);
|
|
1224
1214
|
}) });
|
|
1225
1215
|
}
|
|
1226
1216
|
|
package/dist/index.d.cts
CHANGED
|
@@ -68,7 +68,7 @@ declare function adapterFromTwoWayConverter<From, To, E, ValuePath extends strin
|
|
|
68
68
|
declare function adapterFromPrototype<From, To, ValuePath extends string, Context>(converter: AnnotatedFieldConverter<From, To, ValuePath, Context>, prototype: From): FieldAdapterBuilder<From, To, never, ValuePath, Context>;
|
|
69
69
|
declare function adapterFromPrototype<From, To, E, ValuePath extends string, Context>(converter: TwoWayFieldConverter<From, To, E, ValuePath, Context>, prototype: From): FieldAdapterBuilder<From, To, E, ValuePath, Context>;
|
|
70
70
|
declare function identityAdapter<V, ValuePath extends string, Context>(prototype: V, required?: boolean): FieldAdapterBuilder<V, V, never, ValuePath, Context>;
|
|
71
|
-
declare function listAdapter<E,
|
|
71
|
+
declare function listAdapter<E, ValuePath extends string, Context>(): FieldAdapterBuilder<readonly E[], readonly E[], never, ValuePath, Context>;
|
|
72
72
|
|
|
73
73
|
type FieldAdaptersOfValues<FlattenedValues extends Readonly<Record<string, any>>, TypePathsToValuePaths extends Readonly<Record<keyof FlattenedValues, string>> = Readonly<Record<keyof FlattenedValues, any>>, Context = any> = {
|
|
74
74
|
readonly [K in keyof FlattenedValues]: FieldAdapter<FlattenedValues[K], any, any, TypePathsToValuePaths[K], Context>;
|
|
@@ -318,11 +318,12 @@ type MantineFieldComponent<T, P = T, E = any> = UnsafePartialComponent<Component
|
|
|
318
318
|
|
|
319
319
|
type SuppliedCheckboxProps = Pick<CheckboxProps, 'name' | 'checked' | 'disabled' | 'required' | 'error' | 'onChange' | 'onFocus' | 'onBlur' | 'onKeyUp'>;
|
|
320
320
|
|
|
321
|
-
type SuppliedListProps<Value = any> = {
|
|
321
|
+
type SuppliedListProps<Value = any, ListPath extends string = string> = {
|
|
322
322
|
values: readonly Value[];
|
|
323
|
+
listPath: ListPath;
|
|
323
324
|
};
|
|
324
|
-
declare function DefaultList<Value>({ values, children, }: SuppliedListProps<Value> & {
|
|
325
|
-
children: (value: Value, index: number) => React.ReactNode;
|
|
325
|
+
declare function DefaultList<Value, ListPath extends string>({ values, listPath, children, }: SuppliedListProps<Value, ListPath> & {
|
|
326
|
+
children: (valuePath: `${ListPath}.${number}`, value: Value, index: number) => React.ReactNode;
|
|
326
327
|
}): react_jsx_runtime.JSX.Element;
|
|
327
328
|
|
|
328
329
|
type SuppliedPillProps = Pick<PillProps, 'children' | 'disabled'>;
|
|
@@ -387,7 +388,7 @@ declare class MantineFormImpl<F extends Fields> implements MantineForm<F> {
|
|
|
387
388
|
radio<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioProps>(valuePath: K, value: ValueTypeOfField<F[K]>, Radio: ComponentType<P>): MantineFieldComponent<SuppliedRadioProps, P, ErrorOfField<F[K]>>;
|
|
388
389
|
pill<K extends keyof AllFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedPillProps, PillProps, ErrorOfField<F[K]>>;
|
|
389
390
|
pill<K extends keyof AllFieldsOfFields<F>, P extends SuppliedPillProps>(valuePath: K, Pill: ComponentType<P>): MantineFieldComponent<SuppliedPillProps, P>;
|
|
390
|
-
list<K extends keyof ListFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedListProps<`${K}.${number}`>, ComponentProps<typeof DefaultList
|
|
391
|
+
list<K extends keyof ListFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedListProps<`${K}.${number}`>, ComponentProps<typeof DefaultList<ElementOfArray<F[K]['value']>, K>>>;
|
|
391
392
|
subForm<K extends keyof AllFieldsOfFields<F>, S extends SubFormFields<F, K>>(valuePath: K, SubForm: ComponentType<FormProps<S>>): ComponentType;
|
|
392
393
|
}
|
|
393
394
|
|
package/dist/index.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ declare function adapterFromTwoWayConverter<From, To, E, ValuePath extends strin
|
|
|
68
68
|
declare function adapterFromPrototype<From, To, ValuePath extends string, Context>(converter: AnnotatedFieldConverter<From, To, ValuePath, Context>, prototype: From): FieldAdapterBuilder<From, To, never, ValuePath, Context>;
|
|
69
69
|
declare function adapterFromPrototype<From, To, E, ValuePath extends string, Context>(converter: TwoWayFieldConverter<From, To, E, ValuePath, Context>, prototype: From): FieldAdapterBuilder<From, To, E, ValuePath, Context>;
|
|
70
70
|
declare function identityAdapter<V, ValuePath extends string, Context>(prototype: V, required?: boolean): FieldAdapterBuilder<V, V, never, ValuePath, Context>;
|
|
71
|
-
declare function listAdapter<E,
|
|
71
|
+
declare function listAdapter<E, ValuePath extends string, Context>(): FieldAdapterBuilder<readonly E[], readonly E[], never, ValuePath, Context>;
|
|
72
72
|
|
|
73
73
|
type FieldAdaptersOfValues<FlattenedValues extends Readonly<Record<string, any>>, TypePathsToValuePaths extends Readonly<Record<keyof FlattenedValues, string>> = Readonly<Record<keyof FlattenedValues, any>>, Context = any> = {
|
|
74
74
|
readonly [K in keyof FlattenedValues]: FieldAdapter<FlattenedValues[K], any, any, TypePathsToValuePaths[K], Context>;
|
|
@@ -318,11 +318,12 @@ type MantineFieldComponent<T, P = T, E = any> = UnsafePartialComponent<Component
|
|
|
318
318
|
|
|
319
319
|
type SuppliedCheckboxProps = Pick<CheckboxProps, 'name' | 'checked' | 'disabled' | 'required' | 'error' | 'onChange' | 'onFocus' | 'onBlur' | 'onKeyUp'>;
|
|
320
320
|
|
|
321
|
-
type SuppliedListProps<Value = any> = {
|
|
321
|
+
type SuppliedListProps<Value = any, ListPath extends string = string> = {
|
|
322
322
|
values: readonly Value[];
|
|
323
|
+
listPath: ListPath;
|
|
323
324
|
};
|
|
324
|
-
declare function DefaultList<Value>({ values, children, }: SuppliedListProps<Value> & {
|
|
325
|
-
children: (value: Value, index: number) => React.ReactNode;
|
|
325
|
+
declare function DefaultList<Value, ListPath extends string>({ values, listPath, children, }: SuppliedListProps<Value, ListPath> & {
|
|
326
|
+
children: (valuePath: `${ListPath}.${number}`, value: Value, index: number) => React.ReactNode;
|
|
326
327
|
}): react_jsx_runtime.JSX.Element;
|
|
327
328
|
|
|
328
329
|
type SuppliedPillProps = Pick<PillProps, 'children' | 'disabled'>;
|
|
@@ -387,7 +388,7 @@ declare class MantineFormImpl<F extends Fields> implements MantineForm<F> {
|
|
|
387
388
|
radio<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioProps>(valuePath: K, value: ValueTypeOfField<F[K]>, Radio: ComponentType<P>): MantineFieldComponent<SuppliedRadioProps, P, ErrorOfField<F[K]>>;
|
|
388
389
|
pill<K extends keyof AllFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedPillProps, PillProps, ErrorOfField<F[K]>>;
|
|
389
390
|
pill<K extends keyof AllFieldsOfFields<F>, P extends SuppliedPillProps>(valuePath: K, Pill: ComponentType<P>): MantineFieldComponent<SuppliedPillProps, P>;
|
|
390
|
-
list<K extends keyof ListFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedListProps<`${K}.${number}`>, ComponentProps<typeof DefaultList
|
|
391
|
+
list<K extends keyof ListFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedListProps<`${K}.${number}`>, ComponentProps<typeof DefaultList<ElementOfArray<F[K]['value']>, K>>>;
|
|
391
392
|
subForm<K extends keyof AllFieldsOfFields<F>, S extends SubFormFields<F, K>>(valuePath: K, SubForm: ComponentType<FormProps<S>>): ComponentType;
|
|
392
393
|
}
|
|
393
394
|
|
package/dist/index.js
CHANGED
|
@@ -87,20 +87,6 @@ function unreliableIdentityConverter() {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// field_converters/list_converter.ts
|
|
91
|
-
function listConverter() {
|
|
92
|
-
return function(from, valuePath) {
|
|
93
|
-
const value = from.map(function(_v, i) {
|
|
94
|
-
return `${valuePath}.${i}`;
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
value,
|
|
98
|
-
required: false,
|
|
99
|
-
readonly: false
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
90
|
// field_converters/maybe_identity_converter.ts
|
|
105
91
|
var MaybeIdentityConverter = class {
|
|
106
92
|
constructor(converter, isFrom) {
|
|
@@ -189,8 +175,9 @@ function identityAdapter(prototype, required) {
|
|
|
189
175
|
}
|
|
190
176
|
function listAdapter() {
|
|
191
177
|
return new FieldAdapterBuilder(
|
|
192
|
-
|
|
193
|
-
prototypingFieldValueFactory([])
|
|
178
|
+
annotatedIdentityConverter(false),
|
|
179
|
+
prototypingFieldValueFactory([]),
|
|
180
|
+
unreliableIdentityConverter()
|
|
194
181
|
);
|
|
195
182
|
}
|
|
196
183
|
|
|
@@ -1206,17 +1193,20 @@ function createList(valuePath, List) {
|
|
|
1206
1193
|
const propSource = () => {
|
|
1207
1194
|
const values = [...this.fields[valuePath].value];
|
|
1208
1195
|
return {
|
|
1209
|
-
values
|
|
1196
|
+
values,
|
|
1197
|
+
listPath: valuePath
|
|
1210
1198
|
};
|
|
1211
1199
|
};
|
|
1212
1200
|
return createUnsafePartialObserverComponent(List, propSource);
|
|
1213
1201
|
}
|
|
1214
1202
|
function DefaultList({
|
|
1215
1203
|
values,
|
|
1204
|
+
listPath,
|
|
1216
1205
|
children
|
|
1217
1206
|
}) {
|
|
1218
1207
|
return /* @__PURE__ */ jsx3(Fragment, { children: values.map(function(value, index) {
|
|
1219
|
-
|
|
1208
|
+
const valuePath = `${listPath}.${index}`;
|
|
1209
|
+
return children(valuePath, value, index);
|
|
1220
1210
|
}) });
|
|
1221
1211
|
}
|
|
1222
1212
|
|
package/mantine/create_list.tsx
CHANGED
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
} from './types'
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
export type SuppliedListProps<Value = any> = {
|
|
13
|
+
export type SuppliedListProps<Value = any, ListPath extends string = string> = {
|
|
14
14
|
values: readonly Value[],
|
|
15
|
+
listPath: ListPath,
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function createList<
|
|
@@ -19,6 +20,7 @@ export function createList<
|
|
|
19
20
|
K extends keyof ListFieldsOfFields<F>,
|
|
20
21
|
Props extends SuppliedListProps<ElementOfArray<ValueTypeOfField<F[K]>>> & {
|
|
21
22
|
children: (
|
|
23
|
+
valuePath: `${K}.${number}`,
|
|
22
24
|
value: ElementOfArray<ValueTypeOfField<F[K]>>,
|
|
23
25
|
index: number,
|
|
24
26
|
) => React.ReactNode,
|
|
@@ -32,6 +34,7 @@ export function createList<
|
|
|
32
34
|
const values = [...this.fields[valuePath].value]
|
|
33
35
|
return {
|
|
34
36
|
values,
|
|
37
|
+
listPath: valuePath,
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
return createUnsafePartialObserverComponent(List, propSource)
|
|
@@ -39,16 +42,19 @@ export function createList<
|
|
|
39
42
|
|
|
40
43
|
export function DefaultList<
|
|
41
44
|
Value,
|
|
45
|
+
ListPath extends string,
|
|
42
46
|
>({
|
|
43
47
|
values,
|
|
48
|
+
listPath,
|
|
44
49
|
children,
|
|
45
|
-
}: SuppliedListProps<Value> & {
|
|
46
|
-
children: (value: Value, index: number) => React.ReactNode,
|
|
50
|
+
}: SuppliedListProps<Value, ListPath> & {
|
|
51
|
+
children: (valuePath: `${ListPath}.${number}`, value: Value, index: number) => React.ReactNode,
|
|
47
52
|
}) {
|
|
48
53
|
return (
|
|
49
54
|
<>
|
|
50
55
|
{values.map(function (value, index) {
|
|
51
|
-
|
|
56
|
+
const valuePath: `${ListPath}.${number}` = `${listPath}.${index}`
|
|
57
|
+
return children(valuePath, value, index)
|
|
52
58
|
})}
|
|
53
59
|
</>
|
|
54
60
|
)
|
package/mantine/hooks.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '@mantine/core'
|
|
14
14
|
import {
|
|
15
15
|
Cache,
|
|
16
|
+
type ElementOfArray,
|
|
16
17
|
} from '@strictly/base'
|
|
17
18
|
import { type FormProps } from 'core/props'
|
|
18
19
|
import {
|
|
@@ -362,7 +363,7 @@ class MantineFormImpl<
|
|
|
362
363
|
K extends keyof ListFieldsOfFields<F>,
|
|
363
364
|
>(valuePath: K): MantineFieldComponent<
|
|
364
365
|
SuppliedListProps<`${K}.${number}`>,
|
|
365
|
-
ComponentProps<typeof DefaultList
|
|
366
|
+
ComponentProps<typeof DefaultList<ElementOfArray<F[K]['value']>, K>>
|
|
366
367
|
> {
|
|
367
368
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
368
369
|
return this.listCache.retrieveOrCreate(
|
|
@@ -370,7 +371,7 @@ class MantineFormImpl<
|
|
|
370
371
|
DefaultList,
|
|
371
372
|
) as MantineFieldComponent<
|
|
372
373
|
SuppliedListProps<`${K}.${number}`>,
|
|
373
|
-
ComponentProps<typeof DefaultList
|
|
374
|
+
ComponentProps<typeof DefaultList<ElementOfArray<F[K]['value']>, K>>,
|
|
374
375
|
ErrorOfField<F[K]>
|
|
375
376
|
>
|
|
376
377
|
}
|
|
@@ -38,29 +38,77 @@ exports[`mantine list hooks > renders Populated 1`] = `
|
|
|
38
38
|
class="m_b183c0a2 mantine-Code-root"
|
|
39
39
|
dir="ltr"
|
|
40
40
|
>
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
<span>
|
|
42
|
+
ValuePath:
|
|
43
|
+
$.0
|
|
44
|
+
</span>
|
|
45
|
+
<br />
|
|
46
|
+
<span>
|
|
47
|
+
Value:
|
|
48
|
+
A
|
|
49
|
+
</span>
|
|
50
|
+
<br />
|
|
51
|
+
<span>
|
|
52
|
+
Index:
|
|
53
|
+
0
|
|
54
|
+
</span>
|
|
43
55
|
</code>
|
|
44
56
|
<code
|
|
45
57
|
class="m_b183c0a2 mantine-Code-root"
|
|
46
58
|
dir="ltr"
|
|
47
59
|
>
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
<span>
|
|
61
|
+
ValuePath:
|
|
62
|
+
$.1
|
|
63
|
+
</span>
|
|
64
|
+
<br />
|
|
65
|
+
<span>
|
|
66
|
+
Value:
|
|
67
|
+
B
|
|
68
|
+
</span>
|
|
69
|
+
<br />
|
|
70
|
+
<span>
|
|
71
|
+
Index:
|
|
72
|
+
1
|
|
73
|
+
</span>
|
|
50
74
|
</code>
|
|
51
75
|
<code
|
|
52
76
|
class="m_b183c0a2 mantine-Code-root"
|
|
53
77
|
dir="ltr"
|
|
54
78
|
>
|
|
55
|
-
|
|
56
|
-
|
|
79
|
+
<span>
|
|
80
|
+
ValuePath:
|
|
81
|
+
$.2
|
|
82
|
+
</span>
|
|
83
|
+
<br />
|
|
84
|
+
<span>
|
|
85
|
+
Value:
|
|
86
|
+
C
|
|
87
|
+
</span>
|
|
88
|
+
<br />
|
|
89
|
+
<span>
|
|
90
|
+
Index:
|
|
91
|
+
2
|
|
92
|
+
</span>
|
|
57
93
|
</code>
|
|
58
94
|
<code
|
|
59
95
|
class="m_b183c0a2 mantine-Code-root"
|
|
60
96
|
dir="ltr"
|
|
61
97
|
>
|
|
62
|
-
|
|
63
|
-
|
|
98
|
+
<span>
|
|
99
|
+
ValuePath:
|
|
100
|
+
$.3
|
|
101
|
+
</span>
|
|
102
|
+
<br />
|
|
103
|
+
<span>
|
|
104
|
+
Value:
|
|
105
|
+
D
|
|
106
|
+
</span>
|
|
107
|
+
<br />
|
|
108
|
+
<span>
|
|
109
|
+
Index:
|
|
110
|
+
3
|
|
111
|
+
</span>
|
|
64
112
|
</code>
|
|
65
113
|
</div>
|
|
66
114
|
</div>
|
|
@@ -26,10 +26,20 @@ function Component(props: FormProps<{
|
|
|
26
26
|
>
|
|
27
27
|
<Stack>
|
|
28
28
|
<List>
|
|
29
|
-
{function (valuePath: ListPath) {
|
|
29
|
+
{function (valuePath: ListPath, value: string, index: number) {
|
|
30
30
|
return (
|
|
31
31
|
<Code key={valuePath}>
|
|
32
|
-
|
|
32
|
+
<span>
|
|
33
|
+
ValuePath: {valuePath}
|
|
34
|
+
</span>
|
|
35
|
+
<br />
|
|
36
|
+
<span>
|
|
37
|
+
Value: {value}
|
|
38
|
+
</span>
|
|
39
|
+
<br />
|
|
40
|
+
<span>
|
|
41
|
+
Index: {index}
|
|
42
|
+
</span>
|
|
33
43
|
</Code>
|
|
34
44
|
)
|
|
35
45
|
}}
|
|
@@ -72,10 +82,10 @@ export const Populated: Story = {
|
|
|
72
82
|
readonly: false,
|
|
73
83
|
required: false,
|
|
74
84
|
value: [
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
85
|
+
'A',
|
|
86
|
+
'B',
|
|
87
|
+
'C',
|
|
88
|
+
'D',
|
|
79
89
|
],
|
|
80
90
|
},
|
|
81
91
|
},
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function listConverter() {
|
|
2
|
-
return function (from, valuePath) {
|
|
3
|
-
const value = from.map(function (_v, i) {
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5
|
-
return `${valuePath}.${i}`;
|
|
6
|
-
});
|
|
7
|
-
return {
|
|
8
|
-
value,
|
|
9
|
-
required: false,
|
|
10
|
-
readonly: false,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type AnnotatedFieldConverter } from 'types/field_converters'
|
|
2
|
-
|
|
3
|
-
export function listConverter<
|
|
4
|
-
E,
|
|
5
|
-
K extends string,
|
|
6
|
-
ValuePath extends string,
|
|
7
|
-
Context,
|
|
8
|
-
>(): AnnotatedFieldConverter<readonly E[], K[], ValuePath, Context> {
|
|
9
|
-
return function (from: readonly E[], valuePath: ValuePath) {
|
|
10
|
-
const value = from.map(function (_v, i) {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
12
|
-
return `${valuePath as string}.${i}` as K
|
|
13
|
-
})
|
|
14
|
-
return {
|
|
15
|
-
value,
|
|
16
|
-
required: false,
|
|
17
|
-
readonly: false,
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|