@transitionsag/bloom-form 0.0.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/LICENSE +7 -0
- package/README.md +21 -0
- package/dist/duration-input/index.d.ts +15 -0
- package/dist/duration-input/index.js +134 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/input/index.d.ts +14 -0
- package/dist/input/index.js +69 -0
- package/dist/number-input/index.d.ts +14 -0
- package/dist/number-input/index.js +72 -0
- package/dist/textarea/index.d.ts +14 -0
- package/dist/textarea/index.js +69 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright © 2026 TransitionsAg
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @transitionsag/bloom-form
|
|
2
|
+
|
|
3
|
+
Solid form bindings for Bloom components.
|
|
4
|
+
|
|
5
|
+
Import component-specific bindings from subpaths so applications only load the Bloom inputs they use:
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { FieldDurationInput } from "@transitionsag/bloom-form/duration-input";
|
|
9
|
+
import { FieldInput } from "@transitionsag/bloom-form/input";
|
|
10
|
+
import { FieldNumberInput } from "@transitionsag/bloom-form/number-input";
|
|
11
|
+
import { FieldTextarea } from "@transitionsag/bloom-form/textarea";
|
|
12
|
+
|
|
13
|
+
<FieldDurationInput field={form.field("duration")} label="Duration" min={0} />;
|
|
14
|
+
<FieldInput field={form.field("title")} label="Title" type="text" />;
|
|
15
|
+
<FieldNumberInput field={form.field("price")} label="Price" min={0} />;
|
|
16
|
+
<FieldTextarea field={form.field("description")} label="Description" />;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
MIT.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DurationInputRootProps, type DurationUnit, type DurationValue } from "@transitionsag/bloom";
|
|
2
|
+
import type { FormLeaf } from "@transitionsag/form";
|
|
3
|
+
import { type JSX } from "solid-js";
|
|
4
|
+
export type FieldDurationInputProps<Error extends JSX.Element = JSX.Element> = Omit<DurationInputRootProps, "aria-describedby" | "children" | "defaultValue" | "invalid" | "onFocusChange" | "onValueChange" | "value"> & {
|
|
5
|
+
"aria-describedby"?: string | undefined;
|
|
6
|
+
field: FormLeaf<DurationValue, Error>;
|
|
7
|
+
invalid?: boolean | undefined;
|
|
8
|
+
label: JSX.Element;
|
|
9
|
+
onFocusChange?: DurationInputRootProps["onFocusChange"] | undefined;
|
|
10
|
+
onValueChange?: DurationInputRootProps["onValueChange"] | undefined;
|
|
11
|
+
showError?: boolean | "blur";
|
|
12
|
+
unitLabels?: Partial<Record<DurationUnit, JSX.Element>> | undefined;
|
|
13
|
+
children?: never;
|
|
14
|
+
};
|
|
15
|
+
export declare function FieldDurationInput<Error extends JSX.Element = JSX.Element>(props: FieldDurationInputProps<Error>): JSX.Element;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
2
|
+
import { DurationInput, durationUnits } from "@transitionsag/bloom";
|
|
3
|
+
import { For, Show, createUniqueId, splitProps } from "solid-js";
|
|
4
|
+
//#region src/duration-input/index.tsx
|
|
5
|
+
const defaultUnitLabels = {
|
|
6
|
+
year: "Year",
|
|
7
|
+
month: "Month",
|
|
8
|
+
week: "Week",
|
|
9
|
+
day: "Day",
|
|
10
|
+
hour: "Hour",
|
|
11
|
+
minute: "Minute",
|
|
12
|
+
second: "Second"
|
|
13
|
+
};
|
|
14
|
+
const emptyDurationValue = [{
|
|
15
|
+
value: null,
|
|
16
|
+
unit: null
|
|
17
|
+
}];
|
|
18
|
+
function FieldDurationInput(props) {
|
|
19
|
+
const generatedId = createUniqueId();
|
|
20
|
+
const [local, durationInputProps] = splitProps(props, [
|
|
21
|
+
"aria-describedby",
|
|
22
|
+
"children",
|
|
23
|
+
"field",
|
|
24
|
+
"id",
|
|
25
|
+
"invalid",
|
|
26
|
+
"label",
|
|
27
|
+
"onFocusChange",
|
|
28
|
+
"onValueChange",
|
|
29
|
+
"showError",
|
|
30
|
+
"unitLabels",
|
|
31
|
+
"units"
|
|
32
|
+
]);
|
|
33
|
+
const inputId = () => local.id ?? `field-duration-input-${generatedId}`;
|
|
34
|
+
const errorId = () => `${inputId()}-error`;
|
|
35
|
+
const value = () => local.field.value() ?? emptyDurationValue;
|
|
36
|
+
const parts = () => value().length > 0 ? value() : emptyDurationValue;
|
|
37
|
+
const unitOptions = () => local.units?.length ? local.units : durationUnits;
|
|
38
|
+
const showErrors = () => local.field.errors().length > 0 && local.showError !== false && (local.showError === true || local.field.state.isBlurred());
|
|
39
|
+
return [createComponent(DurationInput, mergeProps(durationInputProps, {
|
|
40
|
+
get id() {
|
|
41
|
+
return inputId();
|
|
42
|
+
},
|
|
43
|
+
get units() {
|
|
44
|
+
return local.units;
|
|
45
|
+
},
|
|
46
|
+
get value() {
|
|
47
|
+
return value();
|
|
48
|
+
},
|
|
49
|
+
get invalid() {
|
|
50
|
+
return local.invalid ?? !local.field.state.isValid();
|
|
51
|
+
},
|
|
52
|
+
onValueChange: (details) => {
|
|
53
|
+
local.field.update(details.value);
|
|
54
|
+
local.onValueChange?.(details);
|
|
55
|
+
},
|
|
56
|
+
onFocusChange: (details) => {
|
|
57
|
+
if (details.index === null) local.field.blur();
|
|
58
|
+
local.onFocusChange?.(details);
|
|
59
|
+
},
|
|
60
|
+
get children() {
|
|
61
|
+
return [
|
|
62
|
+
createComponent(DurationInput.HiddenInput, {}),
|
|
63
|
+
createComponent(DurationInput.Control, { get children() {
|
|
64
|
+
return createComponent(For, {
|
|
65
|
+
get each() {
|
|
66
|
+
return parts();
|
|
67
|
+
},
|
|
68
|
+
children: (_, index) => createComponent(DurationInput.Part, {
|
|
69
|
+
get index() {
|
|
70
|
+
return index();
|
|
71
|
+
},
|
|
72
|
+
get children() {
|
|
73
|
+
return [createComponent(DurationInput.Part.Control, { get children() {
|
|
74
|
+
return [
|
|
75
|
+
createComponent(DurationInput.Part.Input, { get ["aria-describedby"]() {
|
|
76
|
+
return [local["aria-describedby"], showErrors() ? errorId() : void 0].filter((id) => !!id).join(" ") || void 0;
|
|
77
|
+
} }),
|
|
78
|
+
createComponent(DurationInput.Part.Unit.Trigger, {}),
|
|
79
|
+
createComponent(Show, {
|
|
80
|
+
get when() {
|
|
81
|
+
return parts().length > 1;
|
|
82
|
+
},
|
|
83
|
+
get children() {
|
|
84
|
+
return createComponent(DurationInput.Part.Trigger.Remove, {});
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
];
|
|
88
|
+
} }), createComponent(DurationInput.Part.Unit.Positioner, { get children() {
|
|
89
|
+
return createComponent(DurationInput.Part.Unit.Content, { get children() {
|
|
90
|
+
return createComponent(DurationInput.Part.Unit.List, { get children() {
|
|
91
|
+
return createComponent(For, {
|
|
92
|
+
get each() {
|
|
93
|
+
return unitOptions();
|
|
94
|
+
},
|
|
95
|
+
children: (unit) => createComponent(DurationInput.Part.Unit.Item, {
|
|
96
|
+
value: unit,
|
|
97
|
+
get children() {
|
|
98
|
+
return [createComponent(DurationInput.Part.Unit.Item.Text, { get children() {
|
|
99
|
+
return local.unitLabels?.[unit] ?? defaultUnitLabels[unit];
|
|
100
|
+
} }), createComponent(DurationInput.Part.Unit.Item.Indicator, {})];
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
} });
|
|
105
|
+
} });
|
|
106
|
+
} })];
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
} }),
|
|
111
|
+
createComponent(DurationInput.Label, { get children() {
|
|
112
|
+
return local.label;
|
|
113
|
+
} }),
|
|
114
|
+
createComponent(DurationInput.Trigger.Add, {})
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
})), createComponent(Show, {
|
|
118
|
+
get when() {
|
|
119
|
+
return showErrors();
|
|
120
|
+
},
|
|
121
|
+
get children() {
|
|
122
|
+
return createComponent(DurationInput.Error, {
|
|
123
|
+
get id() {
|
|
124
|
+
return errorId();
|
|
125
|
+
},
|
|
126
|
+
get children() {
|
|
127
|
+
return local.field.errors();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
})];
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { FieldDurationInput };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { FieldDurationInput } from "./duration-input/index.js";
|
|
2
|
+
export type { FieldDurationInputProps } from "./duration-input/index.js";
|
|
3
|
+
export { FieldInput } from "./input/index.js";
|
|
4
|
+
export type { FieldInputProps } from "./input/index.js";
|
|
5
|
+
export { FieldNumberInput } from "./number-input/index.js";
|
|
6
|
+
export type { FieldNumberInputProps } from "./number-input/index.js";
|
|
7
|
+
export { FieldTextarea } from "./textarea/index.js";
|
|
8
|
+
export type { FieldTextareaProps } from "./textarea/index.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FieldDurationInput } from "./duration-input/index.js";
|
|
2
|
+
import { FieldInput } from "./input/index.js";
|
|
3
|
+
import { FieldNumberInput } from "./number-input/index.js";
|
|
4
|
+
import { FieldTextarea } from "./textarea/index.js";
|
|
5
|
+
export { FieldDurationInput, FieldInput, FieldNumberInput, FieldTextarea };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type InputRootProps } from "@transitionsag/bloom";
|
|
2
|
+
import type { FormLeaf } from "@transitionsag/form";
|
|
3
|
+
import { type JSX } from "solid-js";
|
|
4
|
+
export type FieldInputProps<Error extends JSX.Element = JSX.Element> = Omit<InputRootProps, "aria-describedby" | "aria-invalid" | "children" | "onBlur" | "onInput" | "value"> & {
|
|
5
|
+
"aria-describedby"?: string | undefined;
|
|
6
|
+
"aria-invalid"?: boolean | "false" | "true" | undefined;
|
|
7
|
+
field: FormLeaf<string, Error>;
|
|
8
|
+
label: JSX.Element;
|
|
9
|
+
onBlur?: JSX.FocusEventHandler<HTMLInputElement, FocusEvent> | undefined;
|
|
10
|
+
onInput?: JSX.InputEventHandler<HTMLInputElement, InputEvent> | undefined;
|
|
11
|
+
showError?: boolean | "blur";
|
|
12
|
+
children?: never;
|
|
13
|
+
};
|
|
14
|
+
export declare function FieldInput<Error extends JSX.Element = JSX.Element>(props: FieldInputProps<Error>): JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
2
|
+
import { Input } from "@transitionsag/bloom";
|
|
3
|
+
import { Show, createUniqueId, splitProps } from "solid-js";
|
|
4
|
+
//#region src/input/index.tsx
|
|
5
|
+
function FieldInput(props) {
|
|
6
|
+
const generatedId = createUniqueId();
|
|
7
|
+
const [local, inputProps] = splitProps(props, [
|
|
8
|
+
"aria-describedby",
|
|
9
|
+
"aria-invalid",
|
|
10
|
+
"children",
|
|
11
|
+
"field",
|
|
12
|
+
"id",
|
|
13
|
+
"label",
|
|
14
|
+
"onBlur",
|
|
15
|
+
"onInput",
|
|
16
|
+
"showError"
|
|
17
|
+
]);
|
|
18
|
+
const inputId = () => local.id ?? `field-input-${generatedId}`;
|
|
19
|
+
const errorId = () => `${inputId()}-error`;
|
|
20
|
+
const showErrors = () => local.field.errors().length > 0 && local.showError !== false && (local.showError === true || local.field.state.isBlurred());
|
|
21
|
+
return [createComponent(Input, mergeProps(inputProps, {
|
|
22
|
+
get id() {
|
|
23
|
+
return inputId();
|
|
24
|
+
},
|
|
25
|
+
get value() {
|
|
26
|
+
return local.field.value() ?? "";
|
|
27
|
+
},
|
|
28
|
+
get ["aria-describedby"]() {
|
|
29
|
+
return [local["aria-describedby"], showErrors() ? errorId() : void 0].filter((id) => !!id).join(" ") || void 0;
|
|
30
|
+
},
|
|
31
|
+
get ["aria-invalid"]() {
|
|
32
|
+
return local["aria-invalid"] ?? (local.field.state.isValid() ? void 0 : "true");
|
|
33
|
+
},
|
|
34
|
+
onInput: (event) => {
|
|
35
|
+
local.field.update(event.currentTarget.value);
|
|
36
|
+
local.onInput?.(event);
|
|
37
|
+
},
|
|
38
|
+
onBlur: (event) => {
|
|
39
|
+
local.field.blur();
|
|
40
|
+
local.onBlur?.(event);
|
|
41
|
+
},
|
|
42
|
+
get children() {
|
|
43
|
+
return createComponent(Input.Label, {
|
|
44
|
+
get ["for"]() {
|
|
45
|
+
return inputId();
|
|
46
|
+
},
|
|
47
|
+
get children() {
|
|
48
|
+
return local.label;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
})), createComponent(Show, {
|
|
53
|
+
get when() {
|
|
54
|
+
return showErrors();
|
|
55
|
+
},
|
|
56
|
+
get children() {
|
|
57
|
+
return createComponent(Input.Error, {
|
|
58
|
+
get id() {
|
|
59
|
+
return errorId();
|
|
60
|
+
},
|
|
61
|
+
get children() {
|
|
62
|
+
return local.field.errors();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
})];
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { FieldInput };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type NumberInputRootProps } from "@transitionsag/bloom";
|
|
2
|
+
import type { FormLeaf } from "@transitionsag/form";
|
|
3
|
+
import { type JSX } from "solid-js";
|
|
4
|
+
export type FieldNumberInputProps<Error extends JSX.Element = JSX.Element> = Omit<NumberInputRootProps, "aria-describedby" | "aria-invalid" | "children" | "defaultValue" | "invalid" | "onBlur" | "onValueChange" | "value"> & {
|
|
5
|
+
"aria-describedby"?: string | undefined;
|
|
6
|
+
field: FormLeaf<number, Error>;
|
|
7
|
+
invalid?: boolean | undefined;
|
|
8
|
+
label: JSX.Element;
|
|
9
|
+
onBlur?: JSX.FocusEventHandler<HTMLInputElement, FocusEvent> | undefined;
|
|
10
|
+
onValueChange?: NumberInputRootProps["onValueChange"] | undefined;
|
|
11
|
+
showError?: boolean | "blur";
|
|
12
|
+
children?: never;
|
|
13
|
+
};
|
|
14
|
+
export declare function FieldNumberInput<Error extends JSX.Element = JSX.Element>(props: FieldNumberInputProps<Error>): JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
2
|
+
import { NumberInput } from "@transitionsag/bloom";
|
|
3
|
+
import { Show, createUniqueId, splitProps } from "solid-js";
|
|
4
|
+
//#region src/number-input/index.tsx
|
|
5
|
+
function FieldNumberInput(props) {
|
|
6
|
+
const generatedId = createUniqueId();
|
|
7
|
+
const [local, numberInputProps] = splitProps(props, [
|
|
8
|
+
"aria-describedby",
|
|
9
|
+
"children",
|
|
10
|
+
"field",
|
|
11
|
+
"id",
|
|
12
|
+
"invalid",
|
|
13
|
+
"label",
|
|
14
|
+
"onBlur",
|
|
15
|
+
"onValueChange",
|
|
16
|
+
"showError"
|
|
17
|
+
]);
|
|
18
|
+
const inputId = () => local.id ?? `field-number-input-${generatedId}`;
|
|
19
|
+
const errorId = () => `${inputId()}-error`;
|
|
20
|
+
const showErrors = () => local.field.errors().length > 0 && local.showError !== false && (local.showError === true || local.field.state.isBlurred());
|
|
21
|
+
return [createComponent(NumberInput, mergeProps(numberInputProps, {
|
|
22
|
+
get id() {
|
|
23
|
+
return inputId();
|
|
24
|
+
},
|
|
25
|
+
get value() {
|
|
26
|
+
return String(local.field.value() ?? "");
|
|
27
|
+
},
|
|
28
|
+
get invalid() {
|
|
29
|
+
return local.invalid ?? !local.field.state.isValid();
|
|
30
|
+
},
|
|
31
|
+
onValueChange: (details) => {
|
|
32
|
+
local.field.update(details.value === "" ? 0 : Number(details.value));
|
|
33
|
+
local.onValueChange?.(details);
|
|
34
|
+
},
|
|
35
|
+
get children() {
|
|
36
|
+
return createComponent(NumberInput.Control, { get children() {
|
|
37
|
+
return [
|
|
38
|
+
createComponent(NumberInput.Input, {
|
|
39
|
+
get ["aria-describedby"]() {
|
|
40
|
+
return [local["aria-describedby"], showErrors() ? errorId() : void 0].filter((id) => !!id).join(" ") || void 0;
|
|
41
|
+
},
|
|
42
|
+
onBlur: (event) => {
|
|
43
|
+
local.field.blur();
|
|
44
|
+
local.onBlur?.(event);
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
createComponent(NumberInput.Label, { get children() {
|
|
48
|
+
return local.label;
|
|
49
|
+
} }),
|
|
50
|
+
createComponent(NumberInput.Minus, {}),
|
|
51
|
+
createComponent(NumberInput.Plus, {})
|
|
52
|
+
];
|
|
53
|
+
} });
|
|
54
|
+
}
|
|
55
|
+
})), createComponent(Show, {
|
|
56
|
+
get when() {
|
|
57
|
+
return showErrors();
|
|
58
|
+
},
|
|
59
|
+
get children() {
|
|
60
|
+
return createComponent(NumberInput.Error, {
|
|
61
|
+
get id() {
|
|
62
|
+
return errorId();
|
|
63
|
+
},
|
|
64
|
+
get children() {
|
|
65
|
+
return local.field.errors();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
})];
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { FieldNumberInput };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type TextareaRootProps } from "@transitionsag/bloom";
|
|
2
|
+
import type { FormLeaf } from "@transitionsag/form";
|
|
3
|
+
import { type JSX } from "solid-js";
|
|
4
|
+
export type FieldTextareaProps<Error extends JSX.Element = JSX.Element> = Omit<TextareaRootProps, "aria-describedby" | "aria-invalid" | "children" | "onBlur" | "onInput" | "value"> & {
|
|
5
|
+
"aria-describedby"?: string | undefined;
|
|
6
|
+
"aria-invalid"?: boolean | "false" | "true" | undefined;
|
|
7
|
+
field: FormLeaf<string, Error>;
|
|
8
|
+
label: JSX.Element;
|
|
9
|
+
onBlur?: JSX.FocusEventHandler<HTMLTextAreaElement, FocusEvent> | undefined;
|
|
10
|
+
onInput?: JSX.InputEventHandler<HTMLTextAreaElement, InputEvent> | undefined;
|
|
11
|
+
showError?: boolean | "blur";
|
|
12
|
+
children?: never;
|
|
13
|
+
};
|
|
14
|
+
export declare function FieldTextarea<Error extends JSX.Element = JSX.Element>(props: FieldTextareaProps<Error>): JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
2
|
+
import { Textarea } from "@transitionsag/bloom";
|
|
3
|
+
import { Show, createUniqueId, splitProps } from "solid-js";
|
|
4
|
+
//#region src/textarea/index.tsx
|
|
5
|
+
function FieldTextarea(props) {
|
|
6
|
+
const generatedId = createUniqueId();
|
|
7
|
+
const [local, textareaProps] = splitProps(props, [
|
|
8
|
+
"aria-describedby",
|
|
9
|
+
"aria-invalid",
|
|
10
|
+
"children",
|
|
11
|
+
"field",
|
|
12
|
+
"id",
|
|
13
|
+
"label",
|
|
14
|
+
"onBlur",
|
|
15
|
+
"onInput",
|
|
16
|
+
"showError"
|
|
17
|
+
]);
|
|
18
|
+
const textareaId = () => local.id ?? `field-textarea-${generatedId}`;
|
|
19
|
+
const errorId = () => `${textareaId()}-error`;
|
|
20
|
+
const showErrors = () => local.field.errors().length > 0 && local.showError !== false && (local.showError === true || local.field.state.isBlurred());
|
|
21
|
+
return [createComponent(Textarea, mergeProps(textareaProps, {
|
|
22
|
+
get id() {
|
|
23
|
+
return textareaId();
|
|
24
|
+
},
|
|
25
|
+
get value() {
|
|
26
|
+
return local.field.value() ?? "";
|
|
27
|
+
},
|
|
28
|
+
get ["aria-describedby"]() {
|
|
29
|
+
return [local["aria-describedby"], showErrors() ? errorId() : void 0].filter((id) => !!id).join(" ") || void 0;
|
|
30
|
+
},
|
|
31
|
+
get ["aria-invalid"]() {
|
|
32
|
+
return local["aria-invalid"] ?? (local.field.state.isValid() ? void 0 : "true");
|
|
33
|
+
},
|
|
34
|
+
onInput: (event) => {
|
|
35
|
+
local.field.update(event.currentTarget.value);
|
|
36
|
+
local.onInput?.(event);
|
|
37
|
+
},
|
|
38
|
+
onBlur: (event) => {
|
|
39
|
+
local.field.blur();
|
|
40
|
+
local.onBlur?.(event);
|
|
41
|
+
},
|
|
42
|
+
get children() {
|
|
43
|
+
return createComponent(Textarea.Label, {
|
|
44
|
+
get ["for"]() {
|
|
45
|
+
return textareaId();
|
|
46
|
+
},
|
|
47
|
+
get children() {
|
|
48
|
+
return local.label;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
})), createComponent(Show, {
|
|
53
|
+
get when() {
|
|
54
|
+
return showErrors();
|
|
55
|
+
},
|
|
56
|
+
get children() {
|
|
57
|
+
return createComponent(Textarea.Error, {
|
|
58
|
+
get id() {
|
|
59
|
+
return errorId();
|
|
60
|
+
},
|
|
61
|
+
get children() {
|
|
62
|
+
return local.field.errors();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
})];
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { FieldTextarea };
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@transitionsag/bloom-form",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"files": [
|
|
6
|
+
"LICENSE",
|
|
7
|
+
"README.md",
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./duration-input": {
|
|
19
|
+
"types": "./dist/duration-input/index.d.ts",
|
|
20
|
+
"import": "./dist/duration-input/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./input": {
|
|
23
|
+
"types": "./dist/input/index.d.ts",
|
|
24
|
+
"import": "./dist/input/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./number-input": {
|
|
27
|
+
"types": "./dist/number-input/index.d.ts",
|
|
28
|
+
"import": "./dist/number-input/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./textarea": {
|
|
31
|
+
"types": "./dist/textarea/index.d.ts",
|
|
32
|
+
"import": "./dist/textarea/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@rolldown-plugin/solid": "^0.0.4",
|
|
37
|
+
"@transitionsag/form": "0.1.0-rc4",
|
|
38
|
+
"rolldown": "^1.0.1",
|
|
39
|
+
"solid-js": "^1.9.13",
|
|
40
|
+
"typescript": "^5.9.3",
|
|
41
|
+
"@transitionsag/bloom": "0.1.0-rc3"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@transitionsag/bloom": "0.0.0",
|
|
45
|
+
"@transitionsag/form": "0.1.0-rc4",
|
|
46
|
+
"solid-js": "^1.9.13"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc --noEmit -p tsconfig.json && rm -rf dist && rolldown -c ../../rolldown.config.ts && tsc -p tsconfig.build.json && node ../../scripts/rewrite-declarations.mjs",
|
|
50
|
+
"check": "tsc --noEmit -p tsconfig.json",
|
|
51
|
+
"clean": "rm -rf dist",
|
|
52
|
+
"fmt": "vp fmt .",
|
|
53
|
+
"lint": "vp lint ."
|
|
54
|
+
}
|
|
55
|
+
}
|