libmodulor 0.14.0 → 0.15.0
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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/esm/dt/base/TBoolean.js +5 -2
- package/dist/esm/std/LLMManager.d.ts +10 -2
- package/dist/esm/std/impl/MistralAILLMManager.d.ts +2 -2
- package/dist/esm/std/impl/MistralAILLMManager.js +2 -2
- package/dist/esm/std/impl/OpenAILLMManager.d.ts +2 -2
- package/dist/esm/std/impl/OpenAILLMManager.js +2 -2
- package/dist/esm/target/lib/react/UCOutputFieldValueFragment.d.ts +3 -2
- package/dist/esm/target/lib/react/common.d.ts +6 -0
- package/dist/esm/target/lib/react/common.js +1 -0
- package/dist/esm/target/lib/react/form.d.ts +8 -7
- package/dist/esm/target/lib/react/touchable.d.ts +3 -2
- package/dist/esm/target/lib/web/input.d.ts +11 -2
- package/dist/esm/target/lib/web/input.js +9 -2
- package/dist/esm/target/react-web-pure/UCEntrypointTouchable.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCEntrypointTouchable.js +2 -2
- package/dist/esm/target/react-web-pure/UCExecTouchable.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCExecTouchable.js +2 -2
- package/dist/esm/target/react-web-pure/UCForm.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCForm.js +3 -4
- package/dist/esm/target/react-web-pure/UCFormField.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormField.js +2 -2
- package/dist/esm/target/react-web-pure/UCFormFieldControl.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormFieldControl.js +7 -5
- package/dist/esm/target/react-web-pure/UCFormFieldDesc.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormFieldDesc.js +2 -2
- package/dist/esm/target/react-web-pure/UCFormFieldErr.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormFieldErr.js +2 -2
- package/dist/esm/target/react-web-pure/UCFormFieldLabel.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormFieldLabel.js +2 -2
- package/dist/esm/target/react-web-pure/UCFormSubmitControl.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormSubmitControl.js +2 -2
- package/dist/esm/target/react-web-pure/UCOutputFieldValue.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCOutputFieldValue.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v0.15.0 (2025-05-25)
|
|
4
|
+
|
|
5
|
+
- In `LLMManager`, allow to pass the `apiKey` directly in the request. It precedes the settings value defined at the implementation level
|
|
6
|
+
- In `target/react`, add optional `className` to stylable components
|
|
7
|
+
- In `target/web`, handle use case input field initial value
|
|
8
|
+
- Add `Embedded` use case examples in the docs
|
|
9
|
+
|
|
3
10
|
## v0.14.0 (2025-05-24)
|
|
4
11
|
|
|
5
12
|
- Introduce `useAction` for react targets : it's a use case agnostic way of invoking an action
|
package/README.md
CHANGED
|
@@ -25,10 +25,13 @@ export class TBoolean extends TBase {
|
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
fmt(ifNullOrUndefined) {
|
|
28
|
-
if (typeof this.raw !== 'boolean'
|
|
28
|
+
if (typeof this.raw !== 'boolean') {
|
|
29
29
|
return super.fmt(ifNullOrUndefined);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
if (this.raw === true) {
|
|
32
|
+
return 'Y';
|
|
33
|
+
}
|
|
34
|
+
return 'N';
|
|
32
35
|
}
|
|
33
36
|
htmlInputType() {
|
|
34
37
|
return 'checkbox';
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type { FreeTextLong } from '../dt/index.js';
|
|
1
|
+
import type { ApiKey, FreeTextLong } from '../dt/index.js';
|
|
2
2
|
export type LLMManagerModel = string;
|
|
3
3
|
export type LLMManagerTemperature = number;
|
|
4
|
+
export interface LLMManagerSendOpts {
|
|
5
|
+
/**
|
|
6
|
+
* By default, each implementation reads the auth from the settings. If provided here, it takes precedence over the settings value.
|
|
7
|
+
*/
|
|
8
|
+
auth?: {
|
|
9
|
+
apiKey?: ApiKey;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
4
12
|
export interface LLMManagerSendReq {
|
|
5
13
|
messages: {
|
|
6
14
|
content: FreeTextLong;
|
|
@@ -21,5 +29,5 @@ export interface LLMManagerSendRes {
|
|
|
21
29
|
}[];
|
|
22
30
|
}
|
|
23
31
|
export interface LLMManager {
|
|
24
|
-
send(req: LLMManagerSendReq): Promise<LLMManagerSendRes>;
|
|
32
|
+
send(req: LLMManagerSendReq, opts?: LLMManagerSendOpts): Promise<LLMManagerSendRes>;
|
|
25
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ApiKey } from '../../dt/index.js';
|
|
2
2
|
import type { HTTPAPICaller } from '../HTTPAPICaller.js';
|
|
3
|
-
import type { LLMManager, LLMManagerSendReq, LLMManagerSendRes } from '../LLMManager.js';
|
|
3
|
+
import type { LLMManager, LLMManagerSendOpts, LLMManagerSendReq, LLMManagerSendRes } from '../LLMManager.js';
|
|
4
4
|
import type { Configurable, Settings, SettingsManager } from '../SettingsManager.js';
|
|
5
5
|
export interface MistralAILLMManagerSettings extends Settings {
|
|
6
6
|
mai_api_key: ApiKey;
|
|
@@ -12,6 +12,6 @@ export declare class MistralAILLMManager implements Configurable<S>, LLMManager
|
|
|
12
12
|
private static BASE_URL;
|
|
13
13
|
constructor(httpAPICaller: HTTPAPICaller, settingsManager: SettingsManager<S>);
|
|
14
14
|
s(): MistralAILLMManagerSettings;
|
|
15
|
-
send(req: LLMManagerSendReq): Promise<LLMManagerSendRes>;
|
|
15
|
+
send(req: LLMManagerSendReq, opts?: LLMManagerSendOpts): Promise<LLMManagerSendRes>;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -26,10 +26,10 @@ let MistralAILLMManager = class MistralAILLMManager {
|
|
|
26
26
|
mai_api_key: this.settingsManager.get()('mai_api_key'),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
async send(req) {
|
|
29
|
+
async send(req, opts) {
|
|
30
30
|
return await this.httpAPICaller.exec({
|
|
31
31
|
authorizationHeader: {
|
|
32
|
-
value: this.s().mai_api_key,
|
|
32
|
+
value: opts?.auth?.apiKey ?? this.s().mai_api_key,
|
|
33
33
|
prefix: 'Bearer',
|
|
34
34
|
},
|
|
35
35
|
errBuilder: async (error) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ApiKey } from '../../dt/index.js';
|
|
2
2
|
import type { HTTPAPICaller } from '../HTTPAPICaller.js';
|
|
3
|
-
import type { LLMManager, LLMManagerSendReq, LLMManagerSendRes } from '../LLMManager.js';
|
|
3
|
+
import type { LLMManager, LLMManagerSendOpts, LLMManagerSendReq, LLMManagerSendRes } from '../LLMManager.js';
|
|
4
4
|
import type { Configurable, Settings, SettingsManager } from '../SettingsManager.js';
|
|
5
5
|
export interface OpenAILLMManagerSettings extends Settings {
|
|
6
6
|
oai_api_key: ApiKey;
|
|
@@ -12,6 +12,6 @@ export declare class OpenAILLMManager implements Configurable<S>, LLMManager {
|
|
|
12
12
|
private static BASE_URL;
|
|
13
13
|
constructor(httpAPICaller: HTTPAPICaller, settingsManager: SettingsManager<S>);
|
|
14
14
|
s(): OpenAILLMManagerSettings;
|
|
15
|
-
send(req: LLMManagerSendReq): Promise<LLMManagerSendRes>;
|
|
15
|
+
send(req: LLMManagerSendReq, opts?: LLMManagerSendOpts): Promise<LLMManagerSendRes>;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -26,10 +26,10 @@ let OpenAILLMManager = class OpenAILLMManager {
|
|
|
26
26
|
oai_api_key: this.settingsManager.get()('oai_api_key'),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
async send(req) {
|
|
29
|
+
async send(req, opts) {
|
|
30
30
|
return await this.httpAPICaller.exec({
|
|
31
31
|
authorizationHeader: {
|
|
32
|
-
value: this.s().oai_api_key,
|
|
32
|
+
value: opts?.auth?.apiKey ?? this.s().oai_api_key,
|
|
33
33
|
prefix: 'Bearer',
|
|
34
34
|
},
|
|
35
35
|
errBuilder: async (error) => error.error.message,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { DataType } from '../../../dt/index.js';
|
|
3
3
|
import type { UCOPIBase, UCOutputField } from '../../../uc/index.js';
|
|
4
|
-
|
|
4
|
+
import type { Stylable } from './common.js';
|
|
5
|
+
export type Props<OPI extends UCOPIBase, T extends DataType> = Stylable & {
|
|
5
6
|
field: UCOutputField<OPI, T>;
|
|
6
7
|
value: T;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
8
9
|
export declare function UCOutputFieldValueFragment<OPI extends UCOPIBase, T extends DataType>({ field, value }: Props<OPI, T>): ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,32 +2,33 @@ import type { ReactElement } from 'react';
|
|
|
2
2
|
import type { DataType, ErrorMessage } from '../../../dt/index.js';
|
|
3
3
|
import type { I18nManager } from '../../../std/index.js';
|
|
4
4
|
import type { UCInput, UCInputField, UCInputFieldChangeOperator, UCInputFieldValue, UCOPIBase } from '../../../uc/index.js';
|
|
5
|
+
import type { Stylable } from './common.js';
|
|
5
6
|
import type { UCPanelCtx, UCPanelOnSubmit, UCPanelState } from './panel.js';
|
|
6
7
|
export type UCFormFieldControlOnChange<T extends DataType = DataType> = (f: UCInputField<T>, op: UCInputFieldChangeOperator, v: UCInputFieldValue<T>) => void;
|
|
7
|
-
export type UCFormFieldControlProps<T extends DataType> = UCPanelState & {
|
|
8
|
+
export type UCFormFieldControlProps<T extends DataType> = Stylable & UCPanelState & {
|
|
8
9
|
errMsg?: ErrorMessage | null;
|
|
9
10
|
f: UCInputField<T>;
|
|
10
11
|
onChange: UCFormFieldControlOnChange<T>;
|
|
11
12
|
};
|
|
12
|
-
export type UCFormFieldDescProps<T extends DataType> = {
|
|
13
|
+
export type UCFormFieldDescProps<T extends DataType> = Stylable & {
|
|
13
14
|
f: UCInputField<T>;
|
|
14
15
|
};
|
|
15
|
-
export type UCFormFieldErrProps = {
|
|
16
|
+
export type UCFormFieldErrProps = Stylable & {
|
|
16
17
|
errMsg?: ErrorMessage | null;
|
|
17
18
|
};
|
|
18
|
-
export type UCFormFieldLabelProps<T extends DataType> = {
|
|
19
|
+
export type UCFormFieldLabelProps<T extends DataType> = Stylable & {
|
|
19
20
|
f: UCInputField<T>;
|
|
20
21
|
};
|
|
21
22
|
export declare const UC_FORM_FIELD_ELEMENTS: readonly ["control", "desc", "err", "label"];
|
|
22
23
|
export type UCFormFieldElement = (typeof UC_FORM_FIELD_ELEMENTS)[number];
|
|
23
|
-
export type UCFormFieldProps<T extends DataType> = UCFormFieldControlProps<T> & {
|
|
24
|
+
export type UCFormFieldProps<T extends DataType> = Stylable & UCFormFieldControlProps<T> & {
|
|
24
25
|
only?: UCFormFieldElement[];
|
|
25
26
|
};
|
|
26
|
-
export type UCFormProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = UCPanelCtx<I, OPI0, OPI1> & {
|
|
27
|
+
export type UCFormProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = Stylable & UCPanelCtx<I, OPI0, OPI1> & {
|
|
27
28
|
onChange: UCFormFieldControlOnChange;
|
|
28
29
|
onSubmit: UCPanelOnSubmit;
|
|
29
30
|
};
|
|
30
|
-
export type UCFormSubmitControlProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = UCPanelCtx<I, OPI0, OPI1> & {
|
|
31
|
+
export type UCFormSubmitControlProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = Stylable & UCPanelCtx<I, OPI0, OPI1> & {
|
|
31
32
|
onPress?: () => Promise<void>;
|
|
32
33
|
};
|
|
33
34
|
export type RenderUCForm<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = (props: UCFormProps<I, OPI0, OPI1>) => ReactElement;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { UCInput, UCOPIBase, UCWording } from '../../../uc/index.js';
|
|
3
|
+
import type { Stylable } from './common.js';
|
|
3
4
|
import type { UCEntrypointCtx } from './entrypoint.js';
|
|
4
5
|
import type { UCPanelCtx, UCPanelOnSubmit } from './panel.js';
|
|
5
|
-
export type UCEntrypointTouchableProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = UCEntrypointCtx<I, OPI0, OPI1> & {
|
|
6
|
+
export type UCEntrypointTouchableProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = Stylable & UCEntrypointCtx<I, OPI0, OPI1> & {
|
|
6
7
|
wording: UCWording;
|
|
7
8
|
};
|
|
8
9
|
export type RenderUCEntrypointTouchable<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = (props: UCEntrypointTouchableProps<I, OPI0, OPI1>) => ReactElement;
|
|
9
|
-
export type UCExecTouchableProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = UCPanelCtx<I, OPI0, OPI1> & {
|
|
10
|
+
export type UCExecTouchableProps<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = Stylable & UCPanelCtx<I, OPI0, OPI1> & {
|
|
10
11
|
onSubmit: UCPanelOnSubmit;
|
|
11
12
|
};
|
|
12
13
|
export type RenderUCExecTouchable<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = (props: UCExecTouchableProps<I, OPI0, OPI1>) => ReactElement;
|
|
@@ -8,9 +8,17 @@ export interface HTMLInputDef {
|
|
|
8
8
|
*/
|
|
9
9
|
internal?: {
|
|
10
10
|
/**
|
|
11
|
-
* When
|
|
11
|
+
* When checked is set, you should probably set `checked` or `defaultChecked` in uncontrolled components (react).
|
|
12
|
+
*/
|
|
13
|
+
checked?: boolean | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* When a field is `multiline`, you should probably render a `<textarea />` instead of an `<input />`.
|
|
12
16
|
*/
|
|
13
17
|
multiline?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* When value is set, you should probably set `value` or `defaultValue` in uncontrolled components (react).
|
|
20
|
+
*/
|
|
21
|
+
value?: string | undefined;
|
|
14
22
|
};
|
|
15
23
|
/**
|
|
16
24
|
* Fields that are part of the W3C spec
|
|
@@ -28,6 +36,7 @@ export interface HTMLInputDef {
|
|
|
28
36
|
spec?: {
|
|
29
37
|
'aria-errormessage'?: string | undefined;
|
|
30
38
|
'aria-invalid'?: boolean | undefined;
|
|
39
|
+
className?: string | undefined;
|
|
31
40
|
disabled?: boolean | undefined;
|
|
32
41
|
id?: string | undefined;
|
|
33
42
|
max?: number | undefined;
|
|
@@ -42,4 +51,4 @@ export interface HTMLInputDef {
|
|
|
42
51
|
type?: HTMLInputType | undefined;
|
|
43
52
|
};
|
|
44
53
|
}
|
|
45
|
-
export declare function htmlInputDef<T extends DataType>(field: UCInputField<T>, execState: UCExecState, errMsg: ErrorMessage | null): HTMLInputDef;
|
|
54
|
+
export declare function htmlInputDef<T extends DataType>(field: UCInputField<T>, execState: UCExecState, errMsg: ErrorMessage | null, className: string | undefined): HTMLInputDef;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TNumber, TString, } from '../../../dt/index.js';
|
|
1
|
+
import { TBoolean, TNumber, TString, } from '../../../dt/index.js';
|
|
2
2
|
import { ucIsDisabled, ucifHint, ucifId, ucifIsMandatory, } from '../../../uc/index.js';
|
|
3
|
-
export function htmlInputDef(field, execState, errMsg) {
|
|
3
|
+
export function htmlInputDef(field, execState, errMsg, className) {
|
|
4
4
|
const def = {
|
|
5
5
|
internal: {},
|
|
6
6
|
spec: {},
|
|
@@ -11,6 +11,7 @@ export function htmlInputDef(field, execState, errMsg) {
|
|
|
11
11
|
}
|
|
12
12
|
const { key, def: fDef } = field;
|
|
13
13
|
const { type: fType } = fDef;
|
|
14
|
+
def.spec.className = className;
|
|
14
15
|
def.spec.disabled = ucIsDisabled(execState);
|
|
15
16
|
def.spec.id = ucifId(key);
|
|
16
17
|
def.spec.name = key;
|
|
@@ -31,6 +32,12 @@ export function htmlInputDef(field, execState, errMsg) {
|
|
|
31
32
|
def.spec.min = fType.min();
|
|
32
33
|
def.spec.step = fType.getStep();
|
|
33
34
|
}
|
|
35
|
+
else if (fType instanceof TBoolean) {
|
|
36
|
+
def.internal.checked = fType.getInitialValue() === true;
|
|
37
|
+
}
|
|
38
|
+
if (!(fType instanceof TBoolean)) {
|
|
39
|
+
def.internal.value = fType.getInitialValue()?.toString() || '';
|
|
40
|
+
}
|
|
34
41
|
def.spec.placeholder = ucifHint(fDef);
|
|
35
42
|
def.spec.required = ucifIsMandatory(fDef);
|
|
36
43
|
def.spec.type = fType.htmlInputType();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { UCInput, UCOPIBase } from '../../uc/index.js';
|
|
3
3
|
import type { UCEntrypointTouchableProps } from '../lib/react/touchable.js';
|
|
4
|
-
export declare function UCEntrypointTouchable<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ path, wording }: UCEntrypointTouchableProps<I, OPI0, OPI1>): ReactElement;
|
|
4
|
+
export declare function UCEntrypointTouchable<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ className, path, wording, }: UCEntrypointTouchableProps<I, OPI0, OPI1>): ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React, {} from 'react';
|
|
2
|
-
export function UCEntrypointTouchable({ path, wording }) {
|
|
3
|
-
return (React.createElement("a", { href: path, title: wording.desc ?? undefined }, wording.label));
|
|
2
|
+
export function UCEntrypointTouchable({ className, path, wording, }) {
|
|
3
|
+
return (React.createElement("a", { className: className, href: path, title: wording.desc ?? undefined }, wording.label));
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { UCInput, UCOPIBase } from '../../uc/index.js';
|
|
3
3
|
import type { UCExecTouchableProps } from '../lib/react/touchable.js';
|
|
4
|
-
export declare function UCExecTouchable<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ disabled, execState, onSubmit, uc, }: UCExecTouchableProps<I, OPI0, OPI1>): ReactElement;
|
|
4
|
+
export declare function UCExecTouchable<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ className, disabled, execState, onSubmit, uc, }: UCExecTouchableProps<I, OPI0, OPI1>): ReactElement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {} from 'react';
|
|
2
2
|
import { useDIContext } from '../lib/react/DIContextProvider.js';
|
|
3
|
-
export function UCExecTouchable({ disabled, execState, onSubmit, uc, }) {
|
|
3
|
+
export function UCExecTouchable({ className, disabled, execState, onSubmit, uc, }) {
|
|
4
4
|
const { wordingManager } = useDIContext();
|
|
5
5
|
const label = wordingManager.ucISubmit(uc.def, execState);
|
|
6
|
-
return (React.createElement("button", { disabled: disabled, onClick: onSubmit, type: "button" }, label));
|
|
6
|
+
return (React.createElement("button", { className: className, disabled: disabled, onClick: onSubmit, type: "button" }, label));
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { UCInput, UCOPIBase } from '../../uc/index.js';
|
|
3
3
|
import type { UCFormProps } from '../lib/react/form.js';
|
|
4
|
-
export declare function UCForm<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ clearAfterExec, disabled, execState, onChange, onSubmit: onSubmitBase, uc, }: UCFormProps<I, OPI0, OPI1>): ReactElement;
|
|
4
|
+
export declare function UCForm<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ className, clearAfterExec, disabled, execState, onChange, onSubmit: onSubmitBase, uc, }: UCFormProps<I, OPI0, OPI1>): ReactElement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
2
|
import { UCFormField } from './UCFormField.js';
|
|
3
3
|
import { UCFormSubmitControl } from './UCFormSubmitControl.js';
|
|
4
|
-
export function UCForm({ clearAfterExec, disabled, execState, onChange, onSubmit: onSubmitBase, uc, }) {
|
|
4
|
+
export function UCForm({ className, clearAfterExec, disabled, execState, onChange, onSubmit: onSubmitBase, uc, }) {
|
|
5
5
|
const formRef = useRef(null);
|
|
6
6
|
const onSubmit = async (e) => {
|
|
7
7
|
e.preventDefault();
|
|
@@ -10,8 +10,7 @@ export function UCForm({ clearAfterExec, disabled, execState, onChange, onSubmit
|
|
|
10
10
|
formRef.current?.reset();
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
return (React.createElement("form", { onSubmit: onSubmit, ref: formRef },
|
|
14
|
-
uc.inputFieldsForForm().map((f) => (React.createElement(
|
|
15
|
-
React.createElement(UCFormField, { disabled: disabled, execState: execState, f: f, onChange: onChange })))),
|
|
13
|
+
return (React.createElement("form", { className: className, onSubmit: onSubmit, ref: formRef },
|
|
14
|
+
uc.inputFieldsForForm().map((f) => (React.createElement(UCFormField, { key: f.key, disabled: disabled, execState: execState, f: f, onChange: onChange }))),
|
|
16
15
|
React.createElement(UCFormSubmitControl, { execState: execState, disabled: disabled, uc: uc })));
|
|
17
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { DataType } from '../../dt/index.js';
|
|
3
3
|
import { type UCFormFieldProps } from '../lib/react/form.js';
|
|
4
|
-
export declare function UCFormField<T extends DataType>({ disabled, execState, f, onChange: onChangeBase, only, }: UCFormFieldProps<T>): ReactElement;
|
|
4
|
+
export declare function UCFormField<T extends DataType>({ className, disabled, execState, f, onChange: onChangeBase, only, }: UCFormFieldProps<T>): ReactElement;
|
|
@@ -5,7 +5,7 @@ import { UCFormFieldControl } from './UCFormFieldControl.js';
|
|
|
5
5
|
import { UCFormFieldDesc } from './UCFormFieldDesc.js';
|
|
6
6
|
import { UCFormFieldErr } from './UCFormFieldErr.js';
|
|
7
7
|
import { UCFormFieldLabel } from './UCFormFieldLabel.js';
|
|
8
|
-
export function UCFormField({ disabled, execState, f, onChange: onChangeBase, only, }) {
|
|
8
|
+
export function UCFormField({ className, disabled, execState, f, onChange: onChangeBase, only, }) {
|
|
9
9
|
const { i18nManager } = useDIContext();
|
|
10
10
|
const [errMsg, setErrMsg] = useState(null);
|
|
11
11
|
const onChange = (f, op, v) => {
|
|
@@ -13,7 +13,7 @@ export function UCFormField({ disabled, execState, f, onChange: onChangeBase, on
|
|
|
13
13
|
onChangeBase(f, op, v);
|
|
14
14
|
};
|
|
15
15
|
const elements = only ?? UC_FORM_FIELD_ELEMENTS;
|
|
16
|
-
return (React.createElement(
|
|
16
|
+
return (React.createElement("div", { className: className },
|
|
17
17
|
elements.includes('label') && React.createElement(UCFormFieldLabel, { f: f }),
|
|
18
18
|
elements.includes('control') && (React.createElement(UCFormFieldControl, { disabled: disabled, execState: execState, f: f, onChange: onChange })),
|
|
19
19
|
elements.includes('err') && errMsg && (React.createElement(UCFormFieldErr, { errMsg: errMsg })),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { DataType } from '../../dt/index.js';
|
|
3
3
|
import type { UCFormFieldControlProps } from '../lib/react/form.js';
|
|
4
|
-
export declare function UCFormFieldControl<T extends DataType>({ errMsg, execState, f, onChange: onChangeBase, }: UCFormFieldControlProps<T>): ReactElement;
|
|
4
|
+
export declare function UCFormFieldControl<T extends DataType>({ className, errMsg, execState, f, onChange: onChangeBase, }: UCFormFieldControlProps<T>): ReactElement;
|
|
@@ -4,8 +4,8 @@ import { htmlInputDef } from '../lib/web/input.js';
|
|
|
4
4
|
const CHECKED_FIELD_TYPES = ['checkbox', 'radio'];
|
|
5
5
|
const FILE_FIELD_TYPES = ['file'];
|
|
6
6
|
const MULTIPLE_VALUES_SEPARATOR = ',';
|
|
7
|
-
export function UCFormFieldControl({ errMsg = null, execState, f, onChange: onChangeBase, }) {
|
|
8
|
-
const attrs = htmlInputDef(f, execState, errMsg);
|
|
7
|
+
export function UCFormFieldControl({ className, errMsg = null, execState, f, onChange: onChangeBase, }) {
|
|
8
|
+
const attrs = htmlInputDef(f, execState, errMsg, className);
|
|
9
9
|
const onChange = (e) => {
|
|
10
10
|
const target = e.currentTarget;
|
|
11
11
|
const type = target.type;
|
|
@@ -33,17 +33,19 @@ export function UCFormFieldControl({ errMsg = null, execState, f, onChange: onCh
|
|
|
33
33
|
onChangeBase(f, UCInputFieldChangeOperator.SET, value);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
+
const defaultChecked = attrs.internal?.checked;
|
|
37
|
+
const defaultValue = attrs.internal?.value;
|
|
36
38
|
if (attrs.internal?.multiline) {
|
|
37
|
-
return React.createElement("textarea", { ...attrs.spec, onChange: onChange });
|
|
39
|
+
return (React.createElement("textarea", { ...attrs.spec, defaultValue: defaultValue, onChange: onChange }));
|
|
38
40
|
}
|
|
39
41
|
const { type } = f.def;
|
|
40
42
|
const options = type.getOptions();
|
|
41
43
|
if (options) {
|
|
42
44
|
// TODO : Handle type.hasStrictOptions() => display an input text alongside the select
|
|
43
45
|
// TODO : Consider using a radio and/or checkbox and/or selectable buttons when the options count < X
|
|
44
|
-
return (React.createElement("select", { ...attrs.spec, onChange: onChange },
|
|
46
|
+
return (React.createElement("select", { ...attrs.spec, defaultValue: defaultValue, onChange: onChange },
|
|
45
47
|
React.createElement("option", null),
|
|
46
48
|
options.map((o) => (React.createElement("option", { key: o.value.toString(), value: o.value.toString() }, o.label)))));
|
|
47
49
|
}
|
|
48
|
-
return React.createElement("input", { ...attrs.spec, onChange: onChange });
|
|
50
|
+
return (React.createElement("input", { ...attrs.spec, defaultChecked: defaultChecked, defaultValue: defaultValue, onChange: onChange }));
|
|
49
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { DataType } from '../../dt/index.js';
|
|
3
3
|
import type { UCFormFieldDescProps } from '../lib/react/form.js';
|
|
4
|
-
export declare function UCFormFieldDesc<T extends DataType>({ f, }: UCFormFieldDescProps<T>): ReactElement | null;
|
|
4
|
+
export declare function UCFormFieldDesc<T extends DataType>({ className, f, }: UCFormFieldDescProps<T>): ReactElement | null;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, {} from 'react';
|
|
2
2
|
import { useDIContext } from '../lib/react/DIContextProvider.js';
|
|
3
|
-
export function UCFormFieldDesc({ f, }) {
|
|
3
|
+
export function UCFormFieldDesc({ className, f, }) {
|
|
4
4
|
const { wordingManager } = useDIContext();
|
|
5
5
|
const { desc } = wordingManager.ucif(f);
|
|
6
6
|
if (!desc) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
return React.createElement("div",
|
|
9
|
+
return React.createElement("div", { className: className }, desc);
|
|
10
10
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { UCFormFieldErrProps } from '../lib/react/form.js';
|
|
3
|
-
export declare function UCFormFieldErr({ errMsg }: UCFormFieldErrProps): ReactElement;
|
|
3
|
+
export declare function UCFormFieldErr({ className, errMsg, }: UCFormFieldErrProps): ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { DataType } from '../../dt/index.js';
|
|
3
3
|
import type { UCFormFieldLabelProps } from '../lib/react/form.js';
|
|
4
|
-
export declare function UCFormFieldLabel<T extends DataType>({ f, }: UCFormFieldLabelProps<T>): ReactElement;
|
|
4
|
+
export declare function UCFormFieldLabel<T extends DataType>({ className, f, }: UCFormFieldLabelProps<T>): ReactElement;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, {} from 'react';
|
|
2
2
|
import { ucifId } from '../../uc/index.js';
|
|
3
3
|
import { useDIContext } from '../lib/react/DIContextProvider.js';
|
|
4
|
-
export function UCFormFieldLabel({ f, }) {
|
|
4
|
+
export function UCFormFieldLabel({ className, f, }) {
|
|
5
5
|
const { wordingManager } = useDIContext();
|
|
6
6
|
const { label } = wordingManager.ucif(f);
|
|
7
|
-
return React.createElement("label", { htmlFor: ucifId(f.key) }, label);
|
|
7
|
+
return (React.createElement("label", { className: className, htmlFor: ucifId(f.key) }, label));
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { UCInput, UCOPIBase } from '../../uc/index.js';
|
|
3
3
|
import type { UCFormSubmitControlProps } from '../lib/react/form.js';
|
|
4
|
-
export declare function UCFormSubmitControl<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ execState, disabled, uc, }: UCFormSubmitControlProps<I, OPI0, OPI1>): ReactElement;
|
|
4
|
+
export declare function UCFormSubmitControl<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ className, execState, disabled, uc, }: UCFormSubmitControlProps<I, OPI0, OPI1>): ReactElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {} from 'react';
|
|
2
2
|
import { useDIContext } from '../lib/react/DIContextProvider.js';
|
|
3
|
-
export function UCFormSubmitControl({ execState, disabled, uc, }) {
|
|
3
|
+
export function UCFormSubmitControl({ className, execState, disabled, uc, }) {
|
|
4
4
|
const { wordingManager } = useDIContext();
|
|
5
|
-
return (React.createElement("input", { disabled: disabled, type: "submit", value: wordingManager.ucISubmit(uc.def, execState) }));
|
|
5
|
+
return (React.createElement("input", { className: className, disabled: disabled, type: "submit", value: wordingManager.ucISubmit(uc.def, execState) }));
|
|
6
6
|
}
|
|
@@ -2,4 +2,4 @@ import { type ReactElement } from 'react';
|
|
|
2
2
|
import type { DataType } from '../../dt/index.js';
|
|
3
3
|
import type { UCOPIBase } from '../../uc/index.js';
|
|
4
4
|
import { type Props } from '../lib/react/UCOutputFieldValueFragment.js';
|
|
5
|
-
export declare function UCOutputFieldValue<OPI extends UCOPIBase, T extends DataType>(
|
|
5
|
+
export declare function UCOutputFieldValue<OPI extends UCOPIBase, T extends DataType>({ className, ...propsWithoutClassName }: Props<OPI, T>): ReactElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {} from 'react';
|
|
2
2
|
import { UCOutputFieldValueFragment, } from '../lib/react/UCOutputFieldValueFragment.js';
|
|
3
|
-
export function UCOutputFieldValue(
|
|
4
|
-
return (React.createElement("span",
|
|
5
|
-
React.createElement(UCOutputFieldValueFragment, { ...
|
|
3
|
+
export function UCOutputFieldValue({ className, ...propsWithoutClassName }) {
|
|
4
|
+
return (React.createElement("span", { className: className },
|
|
5
|
+
React.createElement(UCOutputFieldValueFragment, { ...propsWithoutClassName })));
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libmodulor",
|
|
3
3
|
"description": "A TypeScript library to create platform-agnostic applications",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"license": "LGPL-3.0",
|
|
6
6
|
"author": "Chafik H'nini <chafik.hnini@gmail.com>",
|
|
7
7
|
"homepage": "https://libmodulor.c100k.eu",
|