react-luna-form 0.0.25 → 0.0.27

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 (41) hide show
  1. package/dist/client/cjs/index.js +927 -447
  2. package/dist/client/esm/index.js +916 -436
  3. package/dist/server/cjs/index.js +462 -101
  4. package/dist/server/esm/index.js +463 -102
  5. package/dist/types/luna-core/src/handle/state-event.d.ts +1 -1
  6. package/dist/types/luna-core/src/index.d.ts +1 -0
  7. package/dist/types/luna-core/src/type.d.ts +17 -2
  8. package/dist/types/luna-core/src/util/constant.d.ts +4 -0
  9. package/dist/types/luna-core/src/util/extract.d.ts +2 -1
  10. package/dist/types/luna-core/src/util/is-input.d.ts +4 -3
  11. package/dist/types/luna-core/src/util/is-type.d.ts +1 -0
  12. package/dist/types/luna-core/src/util/list.d.ts +4 -0
  13. package/dist/types/luna-core/src/util/prepare.d.ts +2 -2
  14. package/dist/types/luna-core/src/util/string.d.ts +1 -0
  15. package/dist/types/luna-react/src/client/component/field/field-list.d.ts +2 -0
  16. package/dist/types/luna-react/src/client/component/{wrapper/with-error.d.ts → field/field-with-error.d.ts} +1 -1
  17. package/dist/types/luna-react/src/client/component/{wrapper/with-field-state.d.ts → field/field-with-state.d.ts} +1 -1
  18. package/dist/types/luna-react/src/client/component/guard/list-guard.d.ts +2 -0
  19. package/dist/types/luna-react/src/client/component/guard/visibility-guard.d.ts +6 -0
  20. package/dist/types/luna-react/src/client/component/slot/slot.d.ts +7 -0
  21. package/dist/types/luna-react/src/client/hook/use-field-list.d.ts +2 -0
  22. package/dist/types/luna-react/src/component/chevron-icon.d.ts +3 -0
  23. package/dist/types/luna-react/src/component/column.d.ts +2 -3
  24. package/dist/types/luna-react/src/component/field/field-base.d.ts +4 -2
  25. package/dist/types/luna-react/src/component/field/field-horizontal.d.ts +2 -8
  26. package/dist/types/luna-react/src/component/field/field-list-item.d.ts +8 -0
  27. package/dist/types/luna-react/src/component/field/field-list.d.ts +7 -0
  28. package/dist/types/luna-react/src/component/field/field-set-advanced.d.ts +5 -0
  29. package/dist/types/luna-react/src/component/field/field-set-base.d.ts +7 -0
  30. package/dist/types/luna-react/src/component/field/field-vertical.d.ts +2 -8
  31. package/dist/types/luna-react/src/component/list.d.ts +5 -0
  32. package/dist/types/luna-react/src/component/slot/list-slot.d.ts +2 -0
  33. package/dist/types/luna-react/src/component/slot/slot-base.d.ts +8 -6
  34. package/dist/types/luna-react/src/component/slot/slot-create.d.ts +4 -3
  35. package/dist/types/luna-react/src/component/slot/slot-list.d.ts +12 -0
  36. package/dist/types/luna-react/src/component/slot/slot.d.ts +1 -0
  37. package/package.json +5 -5
  38. package/dist/types/luna-react/src/component/input/input-attributes.d.ts +0 -3
  39. package/dist/types/luna-react/src/component/input/input-common.d.ts +0 -2
  40. package/dist/types/luna-react/src/component/input/input-option-select.d.ts +0 -5
  41. /package/dist/types/luna-react/src/client/component/{wrapper/index.d.ts → field/field.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
1
  import type { FieldState, Nullable, StateEvent } from '../type';
2
- export declare function handleStateEvent<T>(selected: Nullable<T> | undefined, events: StateEvent[] | undefined, setState: (name: string, state?: FieldState) => void): void;
2
+ export declare function handleStateEvent<T>(selected: Nullable<T> | undefined, events: StateEvent[] | undefined, setState: (name: string[], state?: FieldState) => void): void;
@@ -13,6 +13,7 @@ export * from './util/date';
13
13
  export * from './util/extract';
14
14
  export * from './util/is-input';
15
15
  export * from './util/is-type';
16
+ export * from './util/list';
16
17
  export * from './util/logger';
17
18
  export * from './util/prepare';
18
19
  export * from './util/schema';
@@ -35,7 +35,18 @@ export type Option = {
35
35
  label: string;
36
36
  value: string;
37
37
  };
38
- export type Fields = Array<Field | Column>;
38
+ export type List = {
39
+ advanced?: {
40
+ action?: string;
41
+ length?: Length<number>;
42
+ };
43
+ description?: string;
44
+ fields: Array<Field | Column>;
45
+ label?: string;
46
+ name: string;
47
+ type: 'list' | (string & {});
48
+ } & Base;
49
+ export type Fields = Array<Field | Column | List>;
39
50
  export type Base = Orderable & Hideable;
40
51
  export type CommonProps = {
41
52
  disabled?: boolean;
@@ -45,6 +56,7 @@ export type CommonProps = {
45
56
  required?: boolean;
46
57
  };
47
58
  export type Section = {
59
+ advanced?: boolean;
48
60
  compact?: boolean;
49
61
  description?: string;
50
62
  fields?: Fields;
@@ -86,7 +98,7 @@ export type ValueEvent = ActionEvent<'value'> & {
86
98
  };
87
99
  export type StateEvent = ActionEvent<'state'> & {
88
100
  state: FieldState;
89
- target: string;
101
+ target: string | string[];
90
102
  when?: string | string[] | Condition;
91
103
  };
92
104
  export type ChangeEvent = Array<SourceEvent | ValueEvent | StateEvent>;
@@ -172,3 +184,6 @@ export type Style = {
172
184
  orientation?: Orientation;
173
185
  showOptionalLabel?: boolean;
174
186
  };
187
+ export type Filterable = Base & {
188
+ fields?: Filterable[];
189
+ };
@@ -8,6 +8,8 @@ export declare const INPUTS: string[];
8
8
  export declare const TEXTAREA = "textarea";
9
9
  export declare const RADIO = "radio";
10
10
  export declare const CHECKBOX = "checkbox";
11
+ export declare const LIST = "list";
12
+ export declare const DATA_TABLE = "data-table";
11
13
  export declare const SELECT = "select";
12
14
  export declare const SELECT_MONTH = "select/month";
13
15
  export declare const SELECT_YEAR = "select/year";
@@ -39,3 +41,5 @@ export declare const STATE = "state";
39
41
  export declare const COMMON_URL = "http://luna.internal";
40
42
  export declare const VERTICAL = "vertical";
41
43
  export declare const HORIZONTAL = "horizontal";
44
+ export declare const HIDDEN = "hidden";
45
+ export declare const TYPE = "type";
@@ -1,7 +1,7 @@
1
1
  import type { Nullable, Option, Value } from '../type';
2
2
  export declare function getEntity<T>(selected: string, collection?: Nullable<T[]>, entity?: string): NonNullable<T> | {
3
3
  value: string;
4
- } | undefined;
4
+ };
5
5
  export declare function getCurrentValue<T>(value: T, entity?: string): Value | undefined;
6
6
  export declare function getValue<T>(value: Record<string, T>, namespace?: string): T | undefined;
7
7
  export declare function getArray<T>(value: Record<string, T> | T[], namespace?: string): Nullable<T[]>;
@@ -12,3 +12,4 @@ export declare function toOptions<T>(data: T[], options?: Option): (T | {
12
12
  })[];
13
13
  export declare function getType(value?: string): string;
14
14
  export declare function getFormData(formData: FormData): Record<string, unknown>;
15
+ export declare function unflatten(data: Record<string, unknown>): Record<string, unknown>;
@@ -1,4 +1,4 @@
1
- import type { Column, Field, Input, Nullable, Select } from '../type';
1
+ import type { Column, Field, Input, List, Nullable, Select } from '../type';
2
2
  export declare const isSelectMonth: (field: Field) => boolean;
3
3
  export declare const isSelectYear: (field: Field) => boolean;
4
4
  export declare const isCheckbox: (field: Field) => field is Input;
@@ -10,8 +10,9 @@ export declare const isText: (field: Field) => field is Input;
10
10
  export declare const isEmail: (field: Field) => field is Input;
11
11
  export declare const isNumber: (field: Field) => field is Input;
12
12
  export declare function isClickable(field: Field): boolean;
13
- export declare function isColumn(slot: Field | Column): slot is Column;
14
- export declare function isField(slot: Field | Column): slot is Field;
13
+ export declare function isList(slot: Field | Column | List): slot is List;
14
+ export declare function isColumn(slot: Field | Column | List): slot is Column;
15
+ export declare function isField(slot: Field | Column | List): slot is Field;
15
16
  export declare function isOptions(field: Field): field is Input;
16
17
  export declare function isTextable(field: Field): boolean;
17
18
  export declare function isValidValue<T>(value?: Nullable<T>): boolean;
@@ -4,3 +4,4 @@ export declare function isEmpty(value: unknown): boolean;
4
4
  export declare function isValue(value: unknown): value is Value;
5
5
  export declare function isString(value: unknown): value is string;
6
6
  export declare function isDataSource(value: unknown): value is DataSource;
7
+ export declare function isBoolean(value: unknown): value is boolean;
@@ -0,0 +1,4 @@
1
+ import type { List, Nullable } from '../type';
2
+ export declare function isMultiFieldList(list: List): boolean;
3
+ export declare function getInitialList(list: List, value?: Nullable<Record<string, unknown>>): number[];
4
+ export declare function getLabel(list: List): string;
@@ -1,4 +1,4 @@
1
- import type { Base, Definition, Nullable } from '../type';
2
- export declare function prepare<T extends Base>(base?: readonly T[], definition?: Definition): any[];
1
+ import type { Definition, Filterable, Nullable } from '../type';
2
+ export declare function prepare<T extends Filterable>(base?: readonly T[], definition?: Definition): any[];
3
3
  export declare function resolveRefs(base: unknown, definition?: Definition, cache?: Map<object, unknown>, visited?: WeakSet<object>): unknown;
4
4
  export declare function entries<T>(values?: Nullable<Record<string, T>>): [key: string, value: T][];
@@ -3,5 +3,6 @@
3
3
  * Supports nested objects using dot notation (e.g., {user.id}).
4
4
  */
5
5
  export declare function interpolate<T>(template: T, values?: Record<string, unknown>): T;
6
+ export declare function interpolateIfNeeded<T>(template: T, values?: Record<string, unknown>): T;
6
7
  export declare function isInterpolated(template: unknown): boolean;
7
8
  export declare function formatMarkdown<K>(text?: string, callback?: (index: number, url: string, text?: string) => K): (string | K)[] | string | null;
@@ -0,0 +1,2 @@
1
+ import type { ListProps } from '../../../component/field/field-list';
2
+ export declare function FieldList(props: ListProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- export declare function withErrors<P extends {
1
+ export declare function withError<P extends {
2
2
  errors?: Record<string, string[]>;
3
3
  field: {
4
4
  name: string;
@@ -1,4 +1,4 @@
1
- export declare function withFieldState<P extends {
1
+ export declare function withState<P extends {
2
2
  disabled?: boolean;
3
3
  field: {
4
4
  name: string;
@@ -0,0 +1,2 @@
1
+ import type { ListProps } from '../../../component/field/field-list';
2
+ export declare function ListGuard({ children, field, value }: ListProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { Field, Fields, List } from '@luna-form/core';
2
+ export declare function VisibilityGuard(props: Readonly<{
3
+ children: React.ReactNode;
4
+ container?: Field | List;
5
+ fields: Fields;
6
+ }>): import("react").ReactNode;
@@ -0,0 +1,7 @@
1
+ export declare const Slot: (props: Readonly<{
2
+ children: import("../../../type").Children;
3
+ disabled?: boolean;
4
+ fields?: import("@luna-form/core").Fields;
5
+ style?: import("@luna-form/core").Style;
6
+ value?: import("@luna-form/core").Nullable<Record<string, unknown>>;
7
+ }>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { type List, type Nullable } from '@luna-form/core';
2
+ export declare function useFieldList(field: List, value?: Nullable<Record<string, unknown>>): readonly [number[], () => void, (index: number) => void, boolean, boolean, number];
@@ -0,0 +1,3 @@
1
+ export declare function ChevronIcon(props: Readonly<{
2
+ expanded: boolean;
3
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,5 @@
1
1
  import { type Column } from '@luna-form/core';
2
- export type ColumnProps = Readonly<{
2
+ export declare function Column(props: Readonly<{
3
3
  children?: React.ReactNode;
4
4
  column?: Column;
5
- }>;
6
- export declare function Column(props: ColumnProps): import("react/jsx-runtime").JSX.Element;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,13 @@
1
1
  import { type Orientation } from '@luna-form/core';
2
- export declare function FieldBase(props: Readonly<{
2
+ export type FieldLayoutProps = {
3
3
  children: React.ReactNode;
4
- className?: string;
5
4
  disabled?: boolean;
6
5
  errors?: string[];
7
6
  isCheckbox?: boolean;
8
7
  isReversed?: boolean;
9
8
  isClickable?: boolean;
9
+ };
10
+ export declare function FieldBase(props: Readonly<FieldLayoutProps & {
11
+ className?: string;
10
12
  orientation: Orientation;
11
13
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,2 @@
1
- export declare function FieldHorizontal(props: Readonly<{
2
- children: React.ReactNode;
3
- disabled?: boolean;
4
- errors?: string[];
5
- isCheckbox?: boolean;
6
- isReversed?: boolean;
7
- isClickable?: boolean;
8
- }>): import("react/jsx-runtime").JSX.Element;
1
+ import { type FieldLayoutProps } from './field-base';
2
+ export declare function FieldHorizontal(props: Readonly<FieldLayoutProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ export declare function FieldListItem(props: Readonly<{
2
+ canRemove?: boolean;
3
+ children: React.ReactNode;
4
+ index: number;
5
+ isMultiField: boolean;
6
+ label: string;
7
+ onRemove?: (index: number) => void;
8
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { type List, type Nullable } from '@luna-form/core';
2
+ export type ListProps = Readonly<{
3
+ children: (index: number) => React.ReactNode;
4
+ field: List;
5
+ value?: Nullable<Record<string, unknown>>;
6
+ }>;
7
+ export declare function FieldList(props: ListProps): import("react/jsx-runtime").JSX.Element[];
@@ -0,0 +1,5 @@
1
+ import type { Section } from '@luna-form/core';
2
+ export declare function FieldSetAdvanced(props: Readonly<{
3
+ section: Section;
4
+ group: React.ReactNode;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export declare function FieldSetBase(props: Readonly<{
2
+ children?: React.ReactNode;
3
+ description?: string;
4
+ empty?: boolean;
5
+ id?: string;
6
+ title?: string;
7
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,2 @@
1
- export declare function FieldVertical(props: Readonly<{
2
- children: React.ReactNode;
3
- disabled?: boolean;
4
- errors?: string[];
5
- isCheckbox?: boolean;
6
- isReversed?: boolean;
7
- isClickable?: boolean;
8
- }>): import("react/jsx-runtime").JSX.Element;
1
+ import { type FieldLayoutProps } from './field-base';
2
+ export declare function FieldVertical(props: Readonly<FieldLayoutProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import type { List } from '@luna-form/core';
2
+ export declare function List(props: Readonly<{
3
+ children: React.ReactNode;
4
+ field: List;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { ListProps } from '../field/field-list';
2
+ export declare function ListSlot({ children, field, value }: ListProps): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,16 @@
1
- import { type Fields, type Style } from '@luna-form/core';
1
+ import { type Fields, type Nullable, type Style } from '@luna-form/core';
2
2
  import type { Children } from '../../type';
3
- import type { ColumnProps } from '../column';
4
3
  import type { FieldProps } from '../field/field';
5
- export declare function SlotBase<T extends {
6
- column: React.ComponentType<ColumnProps>;
4
+ import type { ListProps } from '../field/field-list';
5
+ export type SlotComponents = {
7
6
  field: React.ComponentType<FieldProps>;
8
- }>(props: Readonly<{
7
+ list: React.ComponentType<ListProps>;
8
+ };
9
+ export declare function SlotBase(props: Readonly<{
9
10
  children: Children;
10
- components: T;
11
+ components: SlotComponents;
11
12
  disabled?: boolean;
12
13
  fields?: Fields;
13
14
  style?: Style;
15
+ value?: Nullable<Record<string, unknown>>;
14
16
  }>): import("react/jsx-runtime").JSX.Element[];
@@ -1,9 +1,10 @@
1
1
  import type { Children } from '../../type';
2
- import type { FieldProps } from '../field/field';
3
- import type { Fields, Style } from '@luna-form/core';
4
- export declare function createSlot(Field: React.ComponentType<FieldProps>): (props: Readonly<{
2
+ import type { Fields, Nullable, Style } from '@luna-form/core';
3
+ import type { SlotComponents } from './slot-base';
4
+ export declare function createSlot(components: SlotComponents): (props: Readonly<{
5
5
  children: Children;
6
6
  disabled?: boolean;
7
7
  fields?: Fields;
8
8
  style?: Style;
9
+ value?: Nullable<Record<string, unknown>>;
9
10
  }>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { type List, type Nullable, type Style } from '@luna-form/core';
2
+ import { type SlotComponents } from './slot-base';
3
+ import type { Children } from '../../type';
4
+ export declare function SlotList(props: Readonly<{
5
+ children: Children;
6
+ components: SlotComponents;
7
+ disabled?: boolean;
8
+ field: List;
9
+ index: number;
10
+ style?: Style;
11
+ value?: Nullable<Record<string, unknown>>;
12
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -3,4 +3,5 @@ export declare const Slot: (props: Readonly<{
3
3
  disabled?: boolean;
4
4
  fields?: import("@luna-form/core").Fields;
5
5
  style?: import("@luna-form/core").Style;
6
+ value?: import("@luna-form/core").Nullable<Record<string, unknown>>;
6
7
  }>) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-luna-form",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
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",
@@ -21,8 +21,8 @@
21
21
  "fast-equals": "^6.0.0",
22
22
  "jotai": "^2.0.0",
23
23
  "jotai-family": "^1.0.0",
24
- "react": "^18.2.0 || ^19.0.0",
25
- "react-dom": "^18.2.0 || ^19.0.0",
24
+ "react": "^19.0.0",
25
+ "react-dom": "^19.0.0",
26
26
  "swr": "^2.0.0",
27
27
  "tailwind-merge": "^3.4.0",
28
28
  "zod": "^4.0.0"
@@ -32,8 +32,8 @@
32
32
  "@types/react-dom": "19.2.3",
33
33
  "eslint-plugin-react": "7.37.5",
34
34
  "eslint-plugin-react-hooks": "7.0.1",
35
- "eslint-plugin-react-refresh": "0.5.0",
36
- "@luna-form/core": "0.0.25"
35
+ "eslint-plugin-react-refresh": "0.5.2",
36
+ "@luna-form/core": "0.0.27"
37
37
  },
38
38
  "license": "Apache-2.0",
39
39
  "repository": {
@@ -1,3 +0,0 @@
1
- import { type Field } from '@luna-form/core';
2
- export declare function buildAriaAttributes(field: Field, errors?: string[]): Record<string, string | number | boolean>;
3
- export declare function buildDataAttributes(field: Field): Record<string, string | number | boolean>;
@@ -1,2 +0,0 @@
1
- import { type CommonProps, type Field } from '@luna-form/core';
2
- export declare function buildCommon(field: Field, disabled?: boolean): CommonProps;
@@ -1,5 +0,0 @@
1
- import { type Field } from '@luna-form/core';
2
- export declare function buildOptionSelect(field: Field): {
3
- value: string;
4
- label: string;
5
- }[] | undefined;