react-luna-form 0.0.31 → 0.0.33

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 (86) hide show
  1. package/dist/client/cjs/index.js +1 -1
  2. package/dist/client/esm/index.js +1 -1
  3. package/dist/config/cjs/index.js +1 -1
  4. package/dist/config/esm/index.js +1 -1
  5. package/dist/server/cjs/index.js +1 -1
  6. package/dist/server/esm/index.js +1 -1
  7. package/dist/types/client/component/field/field-list.d.ts +2 -0
  8. package/dist/types/client/component/field/field-with-state.d.ts +13 -0
  9. package/dist/types/client/component/field/field.d.ts +7 -0
  10. package/dist/types/client/component/form-content.d.ts +20 -0
  11. package/dist/types/client/component/form.d.ts +20 -0
  12. package/dist/types/client/component/guard/list-guard.d.ts +2 -0
  13. package/dist/types/client/component/guard/visibility-guard.d.ts +6 -0
  14. package/dist/types/client/component/input.d.ts +16 -0
  15. package/dist/types/client/component/slot/slot.d.ts +7 -0
  16. package/dist/types/client/hook/use-data-source.d.ts +3 -0
  17. package/dist/types/client/hook/use-fetch.d.ts +3 -0
  18. package/dist/types/client/hook/use-field-list.d.ts +2 -0
  19. package/dist/types/client/hook/use-form-action.d.ts +13 -0
  20. package/dist/types/client/hook/use-input.d.ts +2 -0
  21. package/dist/types/client/hook/use-schema.d.ts +2 -0
  22. package/dist/types/client/hook/use-store.d.ts +1 -0
  23. package/dist/types/client/hook/use-timeout.d.ts +1 -0
  24. package/dist/types/client/hook/use-value.d.ts +6 -0
  25. package/dist/types/client/index.d.ts +3 -0
  26. package/dist/types/client/lib/error-store.d.ts +7 -0
  27. package/dist/types/client/lib/source-store.d.ts +5 -0
  28. package/dist/types/client/lib/state-store.d.ts +5 -0
  29. package/dist/types/client/lib/store-helper.d.ts +26 -0
  30. package/dist/types/client/lib/value-store.d.ts +10 -0
  31. package/dist/types/component/chevron-icon.d.ts +3 -0
  32. package/dist/types/component/column.d.ts +5 -0
  33. package/dist/types/component/control.d.ts +5 -0
  34. package/dist/types/component/description.d.ts +3 -0
  35. package/dist/types/component/field/field-base.d.ts +12 -0
  36. package/dist/types/component/field/field-error.d.ts +5 -0
  37. package/dist/types/component/field/field-group.d.ts +8 -0
  38. package/dist/types/component/field/field-horizontal.d.ts +2 -0
  39. package/dist/types/component/field/field-list-item.d.ts +8 -0
  40. package/dist/types/component/field/field-list.d.ts +7 -0
  41. package/dist/types/component/field/field-set-advanced.d.ts +5 -0
  42. package/dist/types/component/field/field-set-base.d.ts +7 -0
  43. package/dist/types/component/field/field-set.d.ts +6 -0
  44. package/dist/types/component/field/field-vertical.d.ts +2 -0
  45. package/dist/types/component/field/field.d.ts +10 -0
  46. package/dist/types/component/form.d.ts +13 -0
  47. package/dist/types/component/formatted-description.d.ts +7 -0
  48. package/dist/types/component/group.d.ts +4 -0
  49. package/dist/types/component/input/input-base.d.ts +9 -0
  50. package/dist/types/component/input-group.d.ts +10 -0
  51. package/dist/types/component/input-label.d.ts +9 -0
  52. package/dist/types/component/label.d.ts +7 -0
  53. package/dist/types/component/legend.d.ts +4 -0
  54. package/dist/types/component/list.d.ts +5 -0
  55. package/dist/types/component/separator.d.ts +1 -0
  56. package/dist/types/component/slot/list-slot.d.ts +2 -0
  57. package/dist/types/component/slot/slot-base.d.ts +16 -0
  58. package/dist/types/component/slot/slot-create.d.ts +10 -0
  59. package/dist/types/component/slot/slot-list.d.ts +12 -0
  60. package/dist/types/component/slot/slot.d.ts +7 -0
  61. package/dist/types/config/index.d.ts +31 -0
  62. package/dist/types/lib/render-If-exists.d.ts +1 -0
  63. package/dist/types/lib/string.d.ts +1 -0
  64. package/dist/types/luna-core/src/helper/input.d.ts +1 -0
  65. package/dist/types/luna-core/src/type.d.ts +3 -3
  66. package/dist/types/luna-core/src/util/build.d.ts +1 -1
  67. package/dist/types/luna-core/src/util/constant.d.ts +1 -2
  68. package/dist/types/luna-core/src/util/extract.d.ts +1 -0
  69. package/dist/types/luna-core/src/util/is-input.d.ts +1 -1
  70. package/dist/types/luna-core/src/util/style.d.ts +1 -1
  71. package/dist/types/luna-react/src/client/component/input.d.ts +2 -2
  72. package/dist/types/luna-react/src/component/field/field-base.d.ts +1 -2
  73. package/dist/types/luna-react/src/component/field/field-group.d.ts +2 -2
  74. package/dist/types/luna-react/src/component/formatted-description.d.ts +4 -0
  75. package/dist/types/luna-react/src/component/input/input-base.d.ts +2 -2
  76. package/dist/types/luna-react/src/component/input-group.d.ts +2 -2
  77. package/dist/types/luna-react/src/component/input-label.d.ts +2 -2
  78. package/dist/types/luna-react/src/config/index.d.ts +2 -2
  79. package/dist/types/luna-react/src/server/component/input.d.ts +2 -2
  80. package/dist/types/luna-react/src/type.d.ts +2 -2
  81. package/dist/types/server/component/fallback.d.ts +7 -0
  82. package/dist/types/server/component/form.d.ts +13 -0
  83. package/dist/types/server/component/input.d.ts +13 -0
  84. package/dist/types/server/index.d.ts +4 -0
  85. package/dist/types/type.d.ts +29 -0
  86. package/package.json +2 -2
@@ -0,0 +1,31 @@
1
+ import { type Environment, type Protocol } from '@luna-form/core';
2
+ import type { AlertProps, Config, InputConfig } from '../type';
3
+ export declare function defineConfig<T extends React.ElementType>(options: Readonly<{
4
+ alert?: React.ComponentType<AlertProps>;
5
+ env?: Environment;
6
+ fetcher?: {
7
+ remotePatterns?: Array<{
8
+ hostname?: string;
9
+ port?: number;
10
+ protocol?: Protocol;
11
+ }>;
12
+ };
13
+ inputs: Array<InputConfig<T>>;
14
+ style?: {
15
+ compact?: boolean;
16
+ horizontal?: boolean;
17
+ showOptionalLabel?: boolean;
18
+ };
19
+ validation?: {
20
+ blur?: boolean;
21
+ change?: boolean;
22
+ showError?: boolean;
23
+ submit?: boolean;
24
+ };
25
+ }>): Config;
26
+ export declare const defineCheckbox: (input: any) => InputConfig<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>;
27
+ export declare const defineInput: (input: any) => InputConfig<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>;
28
+ export declare const defineRadio: (input: any) => InputConfig<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>;
29
+ export declare const defineSelect: (input: any) => InputConfig<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>;
30
+ export declare const defineTextArea: (input: any) => InputConfig<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>;
31
+ export declare function defineCustomInput<T extends React.ElementType>(types: string | string[], input: React.ComponentProps<T>): InputConfig<T>;
@@ -0,0 +1 @@
1
+ export declare function renderIfExists<T>(value: T | undefined | null, render: (value: T) => React.ReactNode): React.ReactNode;
@@ -0,0 +1 @@
1
+ export declare function formatMarkdown(text?: string): React.ReactNode;
@@ -16,6 +16,7 @@ export declare function mergeOptionsProps(field: Field, commonProps: CommonProps
16
16
  };
17
17
  export declare function getPreselectedValue(field: Field, commonProps: CommonProps, value?: Value): any;
18
18
  export declare function getOptions<T>(field: Field, data?: Nullable<T[]>): (T | {
19
+ description?: string | undefined;
19
20
  label: string;
20
21
  value: string;
21
22
  })[] | null | undefined;
@@ -32,6 +32,7 @@ export type Hideable = {
32
32
  export type Sections = Array<Section>;
33
33
  export type Value = string | number | readonly string[];
34
34
  export type Option = {
35
+ description?: string;
35
36
  label: string;
36
37
  value: string;
37
38
  };
@@ -102,7 +103,6 @@ export type StateEvent = ActionEvent<'state'> & {
102
103
  when?: string | string[] | Condition;
103
104
  };
104
105
  export type ChangeEvent = Array<SourceEvent | ValueEvent | StateEvent>;
105
- export type Orientation = 'horizontal' | 'vertical';
106
106
  export type Validation = {
107
107
  custom?: CustomValidation | Array<CustomValidation>;
108
108
  email?: string;
@@ -116,7 +116,7 @@ export type Field = CommonProps & {
116
116
  cols?: number;
117
117
  data?: DataAttributes;
118
118
  entity?: string;
119
- orientation?: Orientation;
119
+ horizontal?: boolean;
120
120
  reverse?: boolean;
121
121
  };
122
122
  event?: {
@@ -181,7 +181,7 @@ export type BaseConfig<T> = {
181
181
  };
182
182
  export type Style = {
183
183
  compact?: boolean;
184
- orientation?: Orientation;
184
+ horizontal?: boolean;
185
185
  showOptionalLabel?: boolean;
186
186
  };
187
187
  export type Filterable = Base & {
@@ -1,6 +1,6 @@
1
1
  import type { Field, Nullable } from '../type';
2
2
  export declare function buildOptions(field: Field, values?: Nullable<Record<string, unknown>>): Record<string, unknown>[] | undefined;
3
- export declare function buildOrientation(field: Field): import("..").Orientation;
3
+ export declare function buildOrientation(field: Field): boolean;
4
4
  export declare function buildReverse(field: Field): boolean;
5
5
  export declare function buildDisabled(field: Field, disabled?: boolean): boolean;
6
6
  export declare function buildSource(field: Field): import("..").DataSource | unknown[] | undefined;
@@ -15,6 +15,7 @@ export declare const SELECT_MONTH = "select/month";
15
15
  export declare const SELECT_YEAR = "select/year";
16
16
  export declare const SELECTS: string[];
17
17
  export declare const COLUMN = "column";
18
+ export declare const DESCRIPTION = "description";
18
19
  export declare const FIELDS = "fields";
19
20
  export declare const LABEL = "label";
20
21
  export declare const VALUE = "value";
@@ -39,7 +40,5 @@ export declare const SET = "set";
39
40
  export declare const SOURCE = "source";
40
41
  export declare const STATE = "state";
41
42
  export declare const COMMON_URL = "http://luna.internal";
42
- export declare const VERTICAL = "vertical";
43
- export declare const HORIZONTAL = "horizontal";
44
43
  export declare const HIDDEN = "hidden";
45
44
  export declare const TYPE = "type";
@@ -7,6 +7,7 @@ export declare function getValue<T>(value: Record<string, T>, namespace?: string
7
7
  export declare function getArray<T>(value: Record<string, T> | T[], namespace?: string): Nullable<T[]>;
8
8
  export declare function extract<T>(value: Record<string, T>, namespace?: string): T | null;
9
9
  export declare function toOptions<T>(data: T[], options?: Option): (T | {
10
+ description?: string | undefined;
10
11
  label: string;
11
12
  value: string;
12
13
  })[];
@@ -13,6 +13,6 @@ export declare function isClickable(field: Field): boolean;
13
13
  export declare function isList(slot: Field | Column | List): slot is List;
14
14
  export declare function isColumn(slot: Field | Column | List): slot is Column;
15
15
  export declare function isField(slot: Field | Column | List): slot is Field;
16
- export declare function isOptions(field: Field): field is Input;
16
+ export declare function isOptions(field: Field): field is Select;
17
17
  export declare function isTextable(field: Field): boolean;
18
18
  export declare function isValidValue<T>(value?: Nullable<T>): boolean;
@@ -1,6 +1,6 @@
1
1
  import type { Style } from '../type';
2
2
  export declare function mergeStyle(globalStyle?: Style, localStyle?: Style): {
3
3
  compact?: boolean;
4
- orientation?: import("..").Orientation;
4
+ horizontal?: boolean;
5
5
  showOptionalLabel?: boolean;
6
6
  };
@@ -1,4 +1,4 @@
1
- import { type AriaAttributes, type CommonProps, type DataAttributes, type Field, type Nullable, type Orientation, type Schema } from '@luna-form/core';
1
+ import { type AriaAttributes, type CommonProps, type DataAttributes, type Field, type Nullable, type Schema } from '@luna-form/core';
2
2
  import type { Config, InputChange } from '../../type';
3
3
  export declare function Input(props: Readonly<{
4
4
  ariaAttributes?: AriaAttributes;
@@ -7,10 +7,10 @@ export declare function Input(props: Readonly<{
7
7
  context?: Record<string, unknown>;
8
8
  dataAttributes?: DataAttributes;
9
9
  field: Field;
10
+ horizontal?: boolean;
10
11
  onMount: (name: string, schema: Schema, field: Field) => void;
11
12
  onUnmount: (name: string) => void;
12
13
  onValueChange?: (input: InputChange) => void;
13
- orientation?: Orientation;
14
14
  translations?: Record<string, string>;
15
15
  value?: Nullable<Record<string, unknown>>;
16
16
  }>): import("react").ReactNode;
@@ -1,4 +1,3 @@
1
- import { type Orientation } from '@luna-form/core';
2
1
  export type FieldLayoutProps = {
3
2
  children: React.ReactNode;
4
3
  disabled?: boolean;
@@ -9,5 +8,5 @@ export type FieldLayoutProps = {
9
8
  };
10
9
  export declare function FieldBase(props: Readonly<FieldLayoutProps & {
11
10
  className?: string;
12
- orientation: Orientation;
11
+ orientation: 'horizontal' | 'vertical';
13
12
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
- import { type Field, type Orientation } from '@luna-form/core';
1
+ import { type Field } from '@luna-form/core';
2
2
  export declare function FieldGroup(props: Readonly<{
3
3
  children: React.ReactNode;
4
4
  disabled?: boolean;
5
5
  errors?: string[];
6
6
  field: Field;
7
- orientation?: Orientation;
7
+ horizontal?: boolean;
8
8
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,7 @@
1
+ import type { Config } from '../type';
1
2
  export declare function FormattedDescription(props: Readonly<{
3
+ config?: Config;
4
+ context?: Record<string, unknown>;
2
5
  text?: string;
6
+ translations?: Record<string, string>;
3
7
  }>): import("react/jsx-runtime").JSX.Element | null;
@@ -1,9 +1,9 @@
1
- import { type Field, type Orientation } from '@luna-form/core';
1
+ import { type Field } from '@luna-form/core';
2
2
  import type { Children } from '../../type';
3
3
  export declare function InputBase(props: Readonly<{
4
4
  children: Children;
5
5
  disabled?: boolean;
6
6
  errors?: string[];
7
7
  field: Field;
8
- orientation?: Orientation;
8
+ horizontal?: boolean;
9
9
  }>): import("react").ReactNode;
@@ -1,10 +1,10 @@
1
- import { type Field, type Orientation } from '@luna-form/core';
2
1
  import type { Config } from '../type';
2
+ import type { Field } from '@luna-form/core';
3
3
  export declare function InputGroup(props: Readonly<{
4
4
  children: React.ReactNode;
5
5
  config?: Config;
6
6
  context?: Record<string, unknown>;
7
7
  field: Field;
8
+ horizontal?: boolean;
8
9
  translations?: Record<string, string>;
9
- orientation?: Orientation;
10
10
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,9 @@
1
- import { type Field, type Orientation } from '@luna-form/core';
1
+ import { type Field } from '@luna-form/core';
2
2
  import type { Config } from '../type';
3
3
  export declare function InputLabel(props: Readonly<{
4
4
  config?: Config;
5
5
  context?: Record<string, unknown>;
6
6
  field: Field;
7
- orientation?: Orientation;
7
+ horizontal?: boolean;
8
8
  translations?: Record<string, string>;
9
9
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { type Environment, type Orientation, type Protocol } from '@luna-form/core';
1
+ import { type Environment, type Protocol } from '@luna-form/core';
2
2
  import type { AlertProps, Config, InputConfig } from '../type';
3
3
  export declare function defineConfig<T extends React.ElementType>(options: Readonly<{
4
4
  alert?: React.ComponentType<AlertProps>;
@@ -13,7 +13,7 @@ export declare function defineConfig<T extends React.ElementType>(options: Reado
13
13
  inputs: Array<InputConfig<T>>;
14
14
  style?: {
15
15
  compact?: boolean;
16
- orientation?: Orientation;
16
+ horizontal?: boolean;
17
17
  showOptionalLabel?: boolean;
18
18
  };
19
19
  validation?: {
@@ -1,4 +1,4 @@
1
- import { type AriaAttributes, type CommonProps, type DataAttributes, type Field, type Orientation } from '@luna-form/core';
1
+ import { type AriaAttributes, type CommonProps, type DataAttributes, type Field } from '@luna-form/core';
2
2
  import type { Config } from '../../type';
3
3
  export declare function Input(props: Readonly<{
4
4
  ariaAttributes?: AriaAttributes;
@@ -7,7 +7,7 @@ export declare function Input(props: Readonly<{
7
7
  context?: Record<string, unknown>;
8
8
  dataAttributes?: DataAttributes;
9
9
  field: Field;
10
- orientation?: Orientation;
10
+ horizontal?: boolean;
11
11
  translations?: Record<string, string>;
12
12
  value?: Record<string, unknown>;
13
13
  }>): import("react").ReactNode;
@@ -1,4 +1,4 @@
1
- import type { AriaAttributes, BaseConfig, CommonProps, DataAttributes, Field, Fields, FormStateError, Orientation } from '@luna-form/core';
1
+ import type { AriaAttributes, BaseConfig, CommonProps, DataAttributes, Field, Fields, FormStateError } from '@luna-form/core';
2
2
  export type Slot = (props: {
3
3
  disabled?: boolean;
4
4
  fields?: Fields;
@@ -11,7 +11,7 @@ export type Children = (props: {
11
11
  commonProps: CommonProps;
12
12
  dataAttributes?: DataAttributes;
13
13
  field: Field;
14
- orientation?: Orientation;
14
+ horizontal?: boolean;
15
15
  }) => React.ReactNode;
16
16
  export type InputConfig<T extends React.ElementType> = {
17
17
  types: string | string[];
@@ -0,0 +1,7 @@
1
+ import type { Config } from '../../type';
2
+ import type { Sections } from '@luna-form/core';
3
+ export declare function Fallback(props: Readonly<{
4
+ children: React.ReactNode;
5
+ config: Config;
6
+ sections: Sections;
7
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { Config } from '../../type';
2
+ import type { Definition, Sections } from '@luna-form/core';
3
+ export declare function Form(props: Readonly<{
4
+ children?: React.ReactNode;
5
+ config: Config;
6
+ context?: Record<string, unknown>;
7
+ definition?: Definition;
8
+ lang?: string;
9
+ readOnly?: boolean;
10
+ sections: Sections;
11
+ translations?: Record<string, Record<string, string>>;
12
+ value?: Record<string, unknown>;
13
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { type AriaAttributes, type CommonProps, type DataAttributes, type Field } from '@luna-form/core';
2
+ import type { Config } from '../../type';
3
+ export declare function Input(props: Readonly<{
4
+ ariaAttributes?: AriaAttributes;
5
+ commonProps: CommonProps;
6
+ config: Config;
7
+ context?: Record<string, unknown>;
8
+ dataAttributes?: DataAttributes;
9
+ field: Field;
10
+ horizontal?: boolean;
11
+ translations?: Record<string, string>;
12
+ value?: Record<string, unknown>;
13
+ }>): import("react").ReactNode;
@@ -0,0 +1,4 @@
1
+ import { Form } from './component/form';
2
+ import { Fallback } from './component/fallback';
3
+ export { Form, Fallback };
4
+ export type { Sections, Source } from '@luna-form/core';
@@ -0,0 +1,29 @@
1
+ import type { AriaAttributes, BaseConfig, CommonProps, DataAttributes, Field, Fields, FormStateError } from '@luna-form/core';
2
+ export type Slot = (props: {
3
+ disabled?: boolean;
4
+ fields?: Fields;
5
+ }) => React.ReactNode;
6
+ export type Control = ((props: {
7
+ isPending?: boolean;
8
+ }) => React.ReactNode) | React.ReactNode;
9
+ export type Children = (props: {
10
+ ariaAttributes?: AriaAttributes;
11
+ commonProps: CommonProps;
12
+ dataAttributes?: DataAttributes;
13
+ field: Field;
14
+ horizontal?: boolean;
15
+ }) => React.ReactNode;
16
+ export type InputConfig<T extends React.ElementType> = {
17
+ types: string | string[];
18
+ input: React.ComponentProps<T>;
19
+ };
20
+ export type AlertProps = Readonly<FormStateError>;
21
+ export type Config = BaseConfig<React.ComponentProps<React.ElementType>> & {
22
+ alert?: React.ComponentType<AlertProps>;
23
+ };
24
+ export type InputChange = {
25
+ data?: DataAttributes;
26
+ name: string;
27
+ type: string;
28
+ value: unknown;
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-luna-form",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "A React library for building forms based on JSON",
5
5
  "main": "./dist/client/cjs/index.js",
6
6
  "module": "./dist/client/esm/index.js",
@@ -33,7 +33,7 @@
33
33
  "eslint-plugin-react": "7.37.5",
34
34
  "eslint-plugin-react-hooks": "7.0.1",
35
35
  "eslint-plugin-react-refresh": "0.5.2",
36
- "@luna-form/core": "0.0.31"
36
+ "@luna-form/core": "0.0.33"
37
37
  },
38
38
  "license": "Apache-2.0",
39
39
  "repository": {