@dxos/react-ui-form 0.7.5-labs.c0e040f → 0.7.5-labs.d199c0f

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 (56) hide show
  1. package/dist/lib/browser/index.mjs +200 -92
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +224 -116
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +200 -92
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +1 -2
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  12. package/dist/types/src/components/Form/ArrayField.d.ts +1 -2
  13. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  14. package/dist/types/src/components/Form/Defaults.d.ts +5 -6
  15. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/Form.d.ts +2 -2
  17. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormActions.d.ts +1 -2
  19. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormContent.d.ts +2 -3
  21. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/FormContext.d.ts +1 -1
  23. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  24. package/dist/types/src/components/Form/Input.d.ts +2 -2
  25. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +1 -2
  27. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
  28. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +1 -2
  29. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
  30. package/dist/types/src/components/Form/custom/TupleInput.d.ts +1 -2
  31. package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
  32. package/dist/types/src/components/ViewEditor/Test.stories.d.ts +1 -2
  33. package/dist/types/src/components/ViewEditor/Test.stories.d.ts.map +1 -1
  34. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +1 -2
  35. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  36. package/dist/types/src/components/deprecated/Form.d.ts +1 -2
  37. package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
  38. package/dist/types/src/components/deprecated/Form.stories.d.ts +1 -2
  39. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
  40. package/dist/types/src/components/deprecated/FormInput.d.ts +2 -2
  41. package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
  42. package/dist/types/src/components/testing.d.ts +3 -3
  43. package/dist/types/src/components/testing.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  45. package/dist/types/src/util/field.d.ts.map +1 -1
  46. package/dist/types/src/util/formatting.d.ts.map +1 -1
  47. package/package.json +25 -24
  48. package/src/components/Form/Defaults.tsx +1 -1
  49. package/src/components/Form/FormContext.tsx +11 -7
  50. package/src/components/Form/custom/GeoPointInput.tsx +42 -12
  51. package/src/components/Form/custom/SelectOptionsInput.tsx +2 -2
  52. package/src/components/Form/factory.tsx +1 -1
  53. package/src/hooks/useForm.ts +64 -41
  54. package/src/translations.ts +1 -1
  55. package/src/util/field.ts +19 -1
  56. package/src/util/formatting.ts +29 -1
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-form",
3
- "version": "0.7.5-labs.c0e040f",
3
+ "version": "0.7.5-labs.d199c0f",
4
4
  "description": "Data components.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
7
  "license": "MIT",
8
8
  "author": "DXOS.org",
9
+ "type": "module",
9
10
  "exports": {
10
11
  ".": {
11
12
  "types": "./dist/types/src/index.d.ts",
@@ -28,21 +29,21 @@
28
29
  "@radix-ui/react-context": "1.1.1",
29
30
  "date-fns": "^3.3.1",
30
31
  "jsonpath": "^1.1.1",
31
- "@dxos/async": "0.7.5-labs.c0e040f",
32
- "@dxos/debug": "0.7.5-labs.c0e040f",
33
- "@dxos/echo-schema": "0.7.5-labs.c0e040f",
34
- "@dxos/echo-db": "0.7.5-labs.c0e040f",
35
- "@dxos/effect": "0.7.5-labs.c0e040f",
36
- "@dxos/keys": "0.7.5-labs.c0e040f",
37
- "@dxos/invariant": "0.7.5-labs.c0e040f",
38
- "@dxos/live-object": "0.7.5-labs.c0e040f",
39
- "@dxos/log": "0.7.5-labs.c0e040f",
40
- "@dxos/react-client": "0.7.5-labs.c0e040f",
41
- "@dxos/react-ui-list": "0.7.5-labs.c0e040f",
42
- "@dxos/react-ui-pickers": "0.7.5-labs.c0e040f",
43
- "@dxos/react-ui-types": "0.7.5-labs.c0e040f",
44
- "@dxos/schema": "0.7.5-labs.c0e040f",
45
- "@dxos/util": "0.7.5-labs.c0e040f"
32
+ "@dxos/async": "0.7.5-labs.d199c0f",
33
+ "@dxos/debug": "0.7.5-labs.d199c0f",
34
+ "@dxos/echo-db": "0.7.5-labs.d199c0f",
35
+ "@dxos/echo-schema": "0.7.5-labs.d199c0f",
36
+ "@dxos/effect": "0.7.5-labs.d199c0f",
37
+ "@dxos/invariant": "0.7.5-labs.d199c0f",
38
+ "@dxos/live-object": "0.7.5-labs.d199c0f",
39
+ "@dxos/log": "0.7.5-labs.d199c0f",
40
+ "@dxos/react-client": "0.7.5-labs.d199c0f",
41
+ "@dxos/react-ui-list": "0.7.5-labs.d199c0f",
42
+ "@dxos/keys": "0.7.5-labs.d199c0f",
43
+ "@dxos/react-ui-pickers": "0.7.5-labs.d199c0f",
44
+ "@dxos/react-ui-types": "0.7.5-labs.d199c0f",
45
+ "@dxos/schema": "0.7.5-labs.d199c0f",
46
+ "@dxos/util": "0.7.5-labs.d199c0f"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@phosphor-icons/react": "^2.1.5",
@@ -54,12 +55,12 @@
54
55
  "react": "~18.2.0",
55
56
  "react-dom": "~18.2.0",
56
57
  "vite": "5.4.7",
57
- "@dxos/random": "0.7.5-labs.c0e040f",
58
- "@dxos/echo-signals": "0.7.5-labs.c0e040f",
59
- "@dxos/react-ui": "0.7.5-labs.c0e040f",
60
- "@dxos/react-ui-syntax-highlighter": "0.7.5-labs.c0e040f",
61
- "@dxos/react-ui-theme": "0.7.5-labs.c0e040f",
62
- "@dxos/storybook-utils": "0.7.5-labs.c0e040f"
58
+ "@dxos/echo-signals": "0.7.5-labs.d199c0f",
59
+ "@dxos/random": "0.7.5-labs.d199c0f",
60
+ "@dxos/react-ui": "0.7.5-labs.d199c0f",
61
+ "@dxos/react-ui-syntax-highlighter": "0.7.5-labs.d199c0f",
62
+ "@dxos/storybook-utils": "0.7.5-labs.d199c0f",
63
+ "@dxos/react-ui-theme": "0.7.5-labs.d199c0f"
63
64
  },
64
65
  "peerDependencies": {
65
66
  "@effect/schema": "^0.75.5",
@@ -67,8 +68,8 @@
67
68
  "effect": "^3.12.3",
68
69
  "react": "~18.2.0",
69
70
  "react-dom": "~18.2.0",
70
- "@dxos/react-ui": "0.7.5-labs.c0e040f",
71
- "@dxos/react-ui-theme": "0.7.5-labs.c0e040f"
71
+ "@dxos/react-ui": "0.7.5-labs.d199c0f",
72
+ "@dxos/react-ui-theme": "0.7.5-labs.d199c0f"
72
73
  },
73
74
  "publishConfig": {
74
75
  "access": "public"
@@ -182,7 +182,7 @@ export const MarkdownInput = ({
182
182
  disabled={disabled}
183
183
  placeholder={placeholder}
184
184
  value={getValue() ?? ''}
185
- classNames={'min-bs-auto overflow-hidden'}
185
+ classNames={'min-bs-auto max-h-40 overflow-auto'}
186
186
  onChange={(event) => onValueChange(type, event.target.value)}
187
187
  onBlur={onBlur}
188
188
  style={{ resize: 'none' }}
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { createContext, useContext, useEffect, type FocusEvent, type PropsWithChildren } from 'react';
5
+ import React, { createContext, useContext, useEffect, useMemo, type FocusEvent, type PropsWithChildren } from 'react';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
8
  import { type BaseObject, getValue } from '@dxos/echo-schema';
@@ -34,12 +34,16 @@ export type FormInputStateProps = {
34
34
  export const useInputProps = (path: (string | number)[] = []): FormInputStateProps => {
35
35
  const { getStatus, getValue: getFormValue, onValueChange, onTouched } = useFormContext();
36
36
 
37
- return {
38
- getStatus: () => getStatus(path),
39
- getValue: () => getFormValue(path),
40
- onValueChange: (type: SimpleType, value: any) => onValueChange(path, type, value),
41
- onBlur: () => onTouched(path),
42
- };
37
+ const stablePath = useMemo(() => path, [Array.isArray(path) ? path.join('.') : path]);
38
+ return useMemo(
39
+ () => ({
40
+ getStatus: () => getStatus(stablePath),
41
+ getValue: () => getFormValue(stablePath),
42
+ onValueChange: (type: SimpleType, value: any) => onValueChange(stablePath, type, value),
43
+ onBlur: () => onTouched(stablePath),
44
+ }),
45
+ [getStatus, getFormValue, onValueChange, onTouched, stablePath],
46
+ );
43
47
  };
44
48
 
45
49
  export const FormProvider = ({
@@ -2,9 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import React, { useCallback, useState, useEffect, useMemo } from 'react';
6
6
 
7
- import { type GeoPoint } from '@dxos/echo-schema';
7
+ import { type GeoPoint, GeoLocation } from '@dxos/echo-schema';
8
8
  import { Input, useTranslation } from '@dxos/react-ui';
9
9
  import { safeParseFloat } from '@dxos/util';
10
10
 
@@ -14,28 +14,58 @@ import { InputHeader, type InputProps } from '../Input';
14
14
  export const GeoPointInput = ({ type, label, disabled, getStatus, getValue, onValueChange, onBlur }: InputProps) => {
15
15
  const { t } = useTranslation(translationKey);
16
16
  const { status, error } = getStatus();
17
- const [lng = 0, lat = 0] = getValue<GeoPoint>() ?? [];
17
+ const geoPoint = useMemo<GeoPoint>(() => getValue<GeoPoint>() ?? [0, 0], [getValue]);
18
+ const geoLocation = useMemo(() => GeoLocation.fromGeoPoint(geoPoint), [geoPoint]);
19
+
20
+ const [longitudeText, setLongitudeText] = useState(geoLocation.longitude?.toString());
21
+ const [latitudeText, setLatitudeText] = useState(geoLocation.latitude?.toString());
22
+
23
+ useEffect(() => {
24
+ const location = GeoLocation.fromGeoPoint(geoPoint);
25
+ setLongitudeText(location.longitude.toString());
26
+ setLatitudeText(location.latitude.toString());
27
+ }, [geoPoint]);
28
+
29
+ const handleCoordinateChange = useCallback(
30
+ (coordinateType: keyof Pick<GeoLocation, 'longitude' | 'latitude'>, setText: (text: string) => void) =>
31
+ (event: React.ChangeEvent<HTMLInputElement>) => {
32
+ const inputText = event.target.value;
33
+ setText(inputText);
34
+ if (inputText !== '' && inputText !== '-') {
35
+ const coord = safeParseFloat(inputText);
36
+ if (coord !== undefined && !isNaN(coord)) {
37
+ const currentLocation = GeoLocation.fromGeoPoint(getValue<GeoPoint>() ?? [0, 0]);
38
+ const newLocation = { ...currentLocation, [coordinateType]: coord };
39
+ const newValue = GeoLocation.toGeoPoint(newLocation);
40
+ onValueChange(type, newValue);
41
+ }
42
+ }
43
+ },
44
+ [getValue, onValueChange, type],
45
+ );
18
46
 
19
47
  return (
20
48
  <Input.Root validationValence={status}>
21
49
  <InputHeader error={error}>
22
50
  <Input.Label>{label}</Input.Label>
23
51
  </InputHeader>
24
- <div className='grid grid-cols-2 gap-2'>
52
+ <div role='none' className='grid grid-cols-2 gap-2'>
25
53
  <Input.TextInput
26
- type='number'
54
+ type='text'
55
+ pattern='^-?[0-9]*\.?[0-9]*$'
27
56
  disabled={disabled}
28
- placeholder={t('placeholder longitude')}
29
- value={lng}
30
- onChange={(event) => onValueChange(type, [lat, safeParseFloat(event.target.value, 0)])}
57
+ placeholder={t('placeholder latitude')}
58
+ value={latitudeText}
59
+ onChange={handleCoordinateChange('latitude', setLatitudeText)}
31
60
  onBlur={onBlur}
32
61
  />
33
62
  <Input.TextInput
34
- type='number'
63
+ type='text'
64
+ pattern='^-?[0-9]*\.?[0-9]*$'
35
65
  disabled={disabled}
36
- placeholder={t('placeholder latitude')}
37
- value={lat}
38
- onChange={(event) => onValueChange(type, [safeParseFloat(event.target.value, 0), lng])}
66
+ placeholder={t('placeholder longitude')}
67
+ value={longitudeText}
68
+ onChange={handleCoordinateChange('longitude', setLongitudeText)}
39
69
  onBlur={onBlur}
40
70
  />
41
71
  </div>
@@ -8,7 +8,7 @@ import { type SelectOption } from '@dxos/echo-schema';
8
8
  import { PublicKey } from '@dxos/keys';
9
9
  import { type ChromaticPalette, Icon, IconButton, Input, Tag, Toolbar, useTranslation } from '@dxos/react-ui';
10
10
  import { List } from '@dxos/react-ui-list';
11
- import { HuePickerToolbarButton } from '@dxos/react-ui-pickers';
11
+ import { HuePicker } from '@dxos/react-ui-pickers';
12
12
  import { hues, mx } from '@dxos/react-ui-theme';
13
13
 
14
14
  import { translationKey } from '../../../translations';
@@ -154,7 +154,7 @@ export const SelectOptionInput = ({ type, label, disabled, getStatus, getValue,
154
154
  data-no-submit
155
155
  />
156
156
  <Toolbar.Root classNames='p-0 m-0 !is-auto'>
157
- <HuePickerToolbarButton hue={item.color} onChangeHue={handleColorChange(item.id)} />
157
+ <HuePicker value={item.color} onChange={handleColorChange(item.id)} />
158
158
  </Toolbar.Root>
159
159
  <IconButton
160
160
  icon='ph--trash--fill'
@@ -14,7 +14,7 @@ import { GeoPointInput } from './custom';
14
14
  */
15
15
  export const getInputComponent = (type: SimpleType, format?: FormatEnum): InputComponent | undefined => {
16
16
  switch (format) {
17
- case FormatEnum.LatLng:
17
+ case FormatEnum.GeoPoint:
18
18
  return GeoPointInput;
19
19
  case FormatEnum.Markdown:
20
20
  return MarkdownInput;
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2024 DXOS.org
2
+ // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
5
  import { useCallback, useEffect, useMemo, useState } from 'react';
@@ -141,7 +141,7 @@ export const useForm = <T extends BaseObject>({
141
141
  const canSave = useMemo(
142
142
  () =>
143
143
  !saving &&
144
- // Check if any error paths that are touched have errors
144
+ // Check if any error paths that are touched have errors.
145
145
  !Object.entries(touched).some(
146
146
  ([path, isTouched]) =>
147
147
  isTouched &&
@@ -183,32 +183,38 @@ export const useForm = <T extends BaseObject>({
183
183
  [errors],
184
184
  );
185
185
 
186
- const getFormValue = <V>(path: (string | number)[]): V | undefined => {
187
- return getValue(values, createJsonPath(path));
188
- };
186
+ const getFormValue = useCallback<FormHandler<T>['getValue']>(
187
+ <V>(path: (string | number)[]): V | undefined => {
188
+ return getValue(values, createJsonPath(path));
189
+ },
190
+ [values],
191
+ );
189
192
 
190
- const onValueChange = (path: (string | number)[], type: SimpleType, value: any) => {
191
- const jsonPath = createJsonPath(path);
192
- let parsedValue = value;
193
- try {
194
- if (type === 'number') {
195
- parsedValue = parseFloat(value as string) || 0;
193
+ const onValueChange = useCallback<FormHandler<T>['onValueChange']>(
194
+ (path: (string | number)[], type: SimpleType, value: any) => {
195
+ const jsonPath = createJsonPath(path);
196
+ let parsedValue = value;
197
+ try {
198
+ if (type === 'number') {
199
+ parsedValue = parseFloat(value as string) || 0;
200
+ }
201
+ } catch (err) {
202
+ log.catch(err);
203
+ parsedValue = undefined;
196
204
  }
197
- } catch (err) {
198
- log.catch(err);
199
- parsedValue = undefined;
200
- }
201
205
 
202
- const newValues = { ...setValue(values, jsonPath, parsedValue) };
203
- setValues(newValues);
204
- setChanged((prev) => ({ ...prev, [jsonPath]: true }));
205
- onValuesChanged?.(newValues);
206
+ const newValues = { ...setValue(values, jsonPath, parsedValue) };
207
+ setValues(newValues);
208
+ setChanged((prev) => ({ ...prev, [jsonPath]: true }));
209
+ onValuesChanged?.(newValues);
206
210
 
207
- const isValid = validate(newValues);
208
- if (isValid && onValid) {
209
- onValid(newValues, { changed });
210
- }
211
- };
211
+ const isValid = validate(newValues);
212
+ if (isValid && onValid) {
213
+ onValid(newValues, { changed });
214
+ }
215
+ },
216
+ [values, onValuesChanged, validate, onValid, changed],
217
+ );
212
218
 
213
219
  const onTouched = useCallback(
214
220
  (path: (string | number)[]) => {
@@ -219,22 +225,39 @@ export const useForm = <T extends BaseObject>({
219
225
  [validate, values],
220
226
  );
221
227
 
222
- return {
223
- // State.
224
- values,
225
- errors,
226
- touched,
227
- changed,
228
- canSave,
229
- handleSave,
230
- formIsValid,
231
-
232
- // Field utils.
233
- getStatus,
234
- getValue: getFormValue,
235
- onValueChange,
236
- onTouched,
237
- } satisfies FormHandler<T>;
228
+ return useMemo(
229
+ () => ({
230
+ // State.
231
+ values,
232
+ errors,
233
+ touched,
234
+ changed,
235
+ canSave,
236
+ formIsValid,
237
+
238
+ // Actions.
239
+ handleSave,
240
+
241
+ // Field utils.
242
+ getStatus,
243
+ getValue: getFormValue,
244
+ onValueChange,
245
+ onTouched,
246
+ }),
247
+ [
248
+ values,
249
+ errors,
250
+ touched,
251
+ changed,
252
+ canSave,
253
+ formIsValid,
254
+ handleSave,
255
+ getStatus,
256
+ getFormValue,
257
+ onValueChange,
258
+ onTouched,
259
+ ],
260
+ );
238
261
  };
239
262
 
240
263
  const createKeySet = <T extends BaseObject, V>(obj: T, value: V): Record<JsonPath, V> => {
@@ -245,7 +268,7 @@ const createKeySet = <T extends BaseObject, V>(obj: T, value: V): Record<JsonPat
245
268
  const flatMap = (errors: ValidationError[]) => {
246
269
  return errors.reduce(
247
270
  (result, { path, message }) => {
248
- // Convert the validation error path format to our JsonPath format
271
+ // Convert the validation error path format to our JsonPath format.
249
272
  const jsonPath = fromEffectValidationPath(path);
250
273
  if (!(jsonPath in result)) {
251
274
  result[jsonPath] = message;
@@ -36,7 +36,7 @@ export default [
36
36
  'format hostname': 'Hostname',
37
37
  'format integer': 'Integer',
38
38
  'format json': 'JSON',
39
- 'format latlng': 'LatLng',
39
+ 'format latlng': 'Geopoint',
40
40
  'format markdown': 'Markdown',
41
41
  'format percent': 'Percent',
42
42
  'format ref': 'Reference',
package/src/util/field.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { FormatEnum, TypeEnum } from '@dxos/echo-schema';
5
+ import { FormatEnum, GeoLocation, TypeEnum } from '@dxos/echo-schema';
6
6
  import { type ValidationError } from '@dxos/schema';
7
7
 
8
8
  /**
@@ -81,6 +81,24 @@ export const parseValue = ({ type, format, value }: ParseProps) => {
81
81
  return isNaN(date.getTime()) ? null : date;
82
82
  }
83
83
 
84
+ case FormatEnum.GeoPoint: {
85
+ // Parse string in format "lat,long" to GeoPoint [longitude, latitude].
86
+ if (typeof value === 'string') {
87
+ // Only keep digits, decimal points, minus signs, and commas.
88
+ const cleaned = value.replace(/[^0-9.,-]+/g, '');
89
+ const parts = cleaned.split(',');
90
+ if (parts.length === 2) {
91
+ const lat = parseFloat(parts[0]);
92
+ const long = parseFloat(parts[1]);
93
+ if (!isNaN(lat) && !isNaN(long)) {
94
+ return GeoLocation.toGeoPoint({ latitude: lat, longitude: long });
95
+ }
96
+ }
97
+ }
98
+
99
+ return [0, 0];
100
+ }
101
+
84
102
  default: {
85
103
  return value;
86
104
  }
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { FormatEnum, TypeEnum } from '@dxos/echo-schema';
5
+ import { FormatEnum, GeoLocation, TypeEnum } from '@dxos/echo-schema';
6
6
 
7
7
  type ValueFormatProps = {
8
8
  type: TypeEnum;
@@ -73,6 +73,19 @@ export const formatForDisplay = ({ type, format, value, locale = undefined }: Va
73
73
  return date.toLocaleTimeString(locale);
74
74
  }
75
75
  }
76
+ case FormatEnum.GeoPoint: {
77
+ if (value === null || value === undefined) {
78
+ return '';
79
+ }
80
+
81
+ // For GeoPoint format [longitude, latitude].
82
+ if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
83
+ const { latitude, longitude } = GeoLocation.fromGeoPoint(value as [number, number]);
84
+ return `${latitude},${longitude}`;
85
+ }
86
+
87
+ return String(value);
88
+ }
76
89
  default: {
77
90
  if (value === null || value === 'undefined') {
78
91
  return '';
@@ -125,6 +138,21 @@ export const formatForEditing = ({ type, format, value, locale = undefined }: Va
125
138
  const date = new Date(value as number);
126
139
  return date.toISOString().split('T')[1].split('.')[0];
127
140
  }
141
+ case FormatEnum.GeoPoint: {
142
+ // Handle null or undefined
143
+ if (value === null || value === undefined) {
144
+ return '';
145
+ }
146
+
147
+ // For GeoPoint format [longitude, latitude].
148
+ if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
149
+ const { latitude, longitude } = GeoLocation.fromGeoPoint(value as [number, number]);
150
+ return `${latitude},${longitude}`;
151
+ }
152
+
153
+ return String(value);
154
+ }
155
+
128
156
  default: {
129
157
  return String(value);
130
158
  }