foldkit-mixins-form 0.9.0 → 0.10.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/README.md +26 -0
- package/dist/recipes.d.mts +48 -0
- package/dist/recipes.d.mts.map +1 -0
- package/dist/recipes.mjs +132 -0
- package/dist/recipes.mjs.map +1 -0
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -71,6 +71,32 @@ Messages to its reducer; submitting a valid form sends its decoded value to
|
|
|
71
71
|
|
|
72
72
|
The next example replaces this unstyled `Drawn` with field and form styles.
|
|
73
73
|
|
|
74
|
+
## A look for the field and the form
|
|
75
|
+
|
|
76
|
+
The views draw unstyled Slots. `foldkit-mixins-form/recipes` gives both a look
|
|
77
|
+
over the theme's tokens, as `foldkit-mixins-ui`'s `Recipes` do for its
|
|
78
|
+
components (it needs `foldkit-mixins-ui` installed, as `/ui` does):
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { Style } from 'foldkit-mixins'
|
|
82
|
+
import { FieldSlots, FormSlots, FormView } from 'foldkit-mixins-form'
|
|
83
|
+
import { Field, Form } from 'foldkit-mixins-form/recipes'
|
|
84
|
+
|
|
85
|
+
const Looked = FormView.define(Edit, {
|
|
86
|
+
field: FormView.field(Edit).pipe(Style.attach(Style.forSlots(FieldSlots)(Field({})))),
|
|
87
|
+
}).pipe(Style.attach(Style.forSlots(FormSlots)(Form({}))))
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- `Field({})` puts the label over the control and what the field says under it,
|
|
91
|
+
in a grid: a control with no width of its own stretches, a checkbox keeps its
|
|
92
|
+
box. Text, number, a select and a picker's search box take
|
|
93
|
+
`foldkit-mixins-ui`'s field looks, so a form drawn with `UiForm.renderers`
|
|
94
|
+
below looks the same. A failure reads in the error's ink.
|
|
95
|
+
- `Form({})` sets the fields in a column, the list of fields to fix in the
|
|
96
|
+
error's colours, and the submit as the primary button, as wide as its words.
|
|
97
|
+
|
|
98
|
+
Adjust one with `.extend`, never a fork, as `foldkit-mixins-crud/recipes` are.
|
|
99
|
+
|
|
74
100
|
## A form drawn through `foldkit-mixins-ui`
|
|
75
101
|
|
|
76
102
|
Install `foldkit-mixins-ui` and its `@foldkit/ui` peer to use the optional
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A field: its label over its control, then what it says about it, in a grid,
|
|
3
|
+
* which stretches a control with no width of its own and leaves a checkbox its
|
|
4
|
+
* size. A failure reads in the error's ink; a choice of many is a row a finger's
|
|
5
|
+
* height, its box beside its words.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Field: import("foldkit-mixins").SlotRecipe<import("foldkit-mixins").SlotsContract<{
|
|
8
|
+
readonly root: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
9
|
+
readonly label: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
10
|
+
readonly description: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
11
|
+
readonly error: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
12
|
+
readonly checking: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
13
|
+
readonly text: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"TextInput", readonly [import("foldkit-mixins").CapabilityShape<"Focusable", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>]>, readonly [import("foldkit-mixins").EventToken<"input">, import("foldkit-mixins").EventToken<"blur">], readonly [import("foldkit-mixins").AttrToken<"aria-invalid">, import("foldkit-mixins").AttrToken<"aria-describedby">], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
14
|
+
readonly multiline: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"TextInput", readonly [import("foldkit-mixins").CapabilityShape<"Focusable", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>]>, readonly [import("foldkit-mixins").EventToken<"input">, import("foldkit-mixins").EventToken<"blur">], readonly [import("foldkit-mixins").AttrToken<"aria-invalid">, import("foldkit-mixins").AttrToken<"aria-describedby">], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
15
|
+
readonly number: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"TextInput", readonly [import("foldkit-mixins").CapabilityShape<"Focusable", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>]>, readonly [import("foldkit-mixins").EventToken<"input">, import("foldkit-mixins").EventToken<"blur">], readonly [import("foldkit-mixins").AttrToken<"aria-invalid">, import("foldkit-mixins").AttrToken<"aria-describedby">], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
16
|
+
readonly toggle: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">, import("foldkit-mixins").EventToken<"blur">], readonly [import("foldkit-mixins").AttrToken<"aria-invalid">, import("foldkit-mixins").AttrToken<"aria-describedby">], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
17
|
+
readonly select: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Focusable", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"change">, import("foldkit-mixins").EventToken<"blur">], readonly [import("foldkit-mixins").AttrToken<"aria-invalid">, import("foldkit-mixins").AttrToken<"aria-describedby">], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
18
|
+
readonly option: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
19
|
+
readonly control: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
20
|
+
readonly group: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
21
|
+
readonly affix: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
22
|
+
readonly choices: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Collection", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
23
|
+
readonly choice: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
24
|
+
readonly choiceLabel: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
25
|
+
readonly search: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"TextInput", readonly [import("foldkit-mixins").CapabilityShape<"Focusable", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>]>, readonly [import("foldkit-mixins").EventToken<"input">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
26
|
+
readonly more: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
27
|
+
}>, {}>;
|
|
28
|
+
/**
|
|
29
|
+
* A form: its fields in a column, a failure that is no one field's in the error's
|
|
30
|
+
* ink, the list of fields to fix in a box of the error's colours, and the submit
|
|
31
|
+
* as the page's primary button, as wide as its words.
|
|
32
|
+
*/
|
|
33
|
+
export declare const Form: import("foldkit-mixins").SlotRecipe<import("foldkit-mixins").SlotsContract<{
|
|
34
|
+
readonly root: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"submit">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
35
|
+
readonly errors: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
36
|
+
readonly summary: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
37
|
+
readonly summaryTitle: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
38
|
+
readonly issues: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Collection", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
39
|
+
readonly issue: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
40
|
+
readonly issueLink: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
41
|
+
readonly submit: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly [import("foldkit-mixins").AttrToken<"disabled">], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
42
|
+
readonly group: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
43
|
+
readonly legend: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
44
|
+
readonly row: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
45
|
+
readonly add: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
46
|
+
readonly remove: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
47
|
+
}>, {}>;
|
|
48
|
+
//# sourceMappingURL=recipes.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipes.d.mts","names":[],"sources":["../src/recipes.ts"],"mappings":";;;;;;qBA0Ca,gCAAK,oCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCL,+BAAI,oCAAA"}
|
package/dist/recipes.mjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { n as FormSlots, t as FieldSlots } from "./src-Bcr4mhQ-.mjs";
|
|
2
|
+
import { Layers, Style } from "foldkit-mixins";
|
|
3
|
+
import { Recipes } from "foldkit-mixins-ui";
|
|
4
|
+
import { Theme } from "foldkit-mixins/theme";
|
|
5
|
+
// src/recipes.ts
|
|
6
|
+
/**
|
|
7
|
+
* Looks for the form view's Slots over the shipped tokens, from
|
|
8
|
+
* `foldkit-mixins-form/recipes`: `Style.forSlots(FieldSlots)(Field({}))` and
|
|
9
|
+
* `Style.forSlots(FormSlots)(Form({}))`. Text, number, select and the relation
|
|
10
|
+
* picker's search box take `foldkit-mixins-ui`'s own field looks, so a form drawn
|
|
11
|
+
* with the plain renderers and one drawn with `UiForm.renderers` look the same.
|
|
12
|
+
*/
|
|
13
|
+
const ref = Theme.ref(Theme.standard());
|
|
14
|
+
const component = (...pieces) => Layers.standard.in("components", Style.compose(...pieces));
|
|
15
|
+
const input = Recipes.Input({}).input ?? Style.empty;
|
|
16
|
+
const button = (options) => Recipes.Button(options).button ?? Style.empty;
|
|
17
|
+
/** A small button that keeps its own width in a field or form that stretches its parts. */
|
|
18
|
+
const small = component(button({
|
|
19
|
+
tone: "neutral",
|
|
20
|
+
variant: "outline",
|
|
21
|
+
size: "sm"
|
|
22
|
+
}), Style.self({ justifySelf: "start" }));
|
|
23
|
+
/** A checkbox the browser draws, a size to see and in the accent. */
|
|
24
|
+
const box = component(Style.self({
|
|
25
|
+
inlineSize: "1rem",
|
|
26
|
+
blockSize: "1rem",
|
|
27
|
+
margin: "0",
|
|
28
|
+
accentColor: ref.accent.default
|
|
29
|
+
}));
|
|
30
|
+
/** A line the field says under its control. */
|
|
31
|
+
const said = (color) => component(Style.self({
|
|
32
|
+
margin: "0",
|
|
33
|
+
fontSize: ref.size.sm,
|
|
34
|
+
color
|
|
35
|
+
}));
|
|
36
|
+
/**
|
|
37
|
+
* A field: its label over its control, then what it says about it, in a grid,
|
|
38
|
+
* which stretches a control with no width of its own and leaves a checkbox its
|
|
39
|
+
* size. A failure reads in the error's ink; a choice of many is a row a finger's
|
|
40
|
+
* height, its box beside its words.
|
|
41
|
+
*/
|
|
42
|
+
const Field = Style.recipeFor(FieldSlots)({ base: {
|
|
43
|
+
root: component(Style.self({
|
|
44
|
+
display: "grid",
|
|
45
|
+
gap: ref.space["2xs"]
|
|
46
|
+
})),
|
|
47
|
+
label: component(Style.self({
|
|
48
|
+
fontSize: ref.size.sm,
|
|
49
|
+
fontWeight: ref.weight.medium,
|
|
50
|
+
color: ref.text.overt
|
|
51
|
+
})),
|
|
52
|
+
description: said(ref.text.muted),
|
|
53
|
+
checking: said(ref.text.muted),
|
|
54
|
+
error: said(ref.error.ink),
|
|
55
|
+
text: input,
|
|
56
|
+
number: input,
|
|
57
|
+
multiline: Recipes.Textarea({}).textarea ?? Style.empty,
|
|
58
|
+
select: Recipes.Select({}).select ?? Style.empty,
|
|
59
|
+
toggle: box,
|
|
60
|
+
choices: component(Style.self({
|
|
61
|
+
display: "grid",
|
|
62
|
+
gap: ref.space["3xs"]
|
|
63
|
+
})),
|
|
64
|
+
choiceLabel: component(Style.self({
|
|
65
|
+
display: "flex",
|
|
66
|
+
alignItems: "center",
|
|
67
|
+
gap: ref.space.xs,
|
|
68
|
+
minBlockSize: "1.5rem"
|
|
69
|
+
})),
|
|
70
|
+
choice: box,
|
|
71
|
+
group: Recipes.InputGroup.group,
|
|
72
|
+
affix: Recipes.InputGroup.affix,
|
|
73
|
+
search: input,
|
|
74
|
+
more: small
|
|
75
|
+
} });
|
|
76
|
+
/**
|
|
77
|
+
* A form: its fields in a column, a failure that is no one field's in the error's
|
|
78
|
+
* ink, the list of fields to fix in a box of the error's colours, and the submit
|
|
79
|
+
* as the page's primary button, as wide as its words.
|
|
80
|
+
*/
|
|
81
|
+
const Form = Style.recipeFor(FormSlots)({ base: {
|
|
82
|
+
root: component(Style.self({
|
|
83
|
+
display: "grid",
|
|
84
|
+
gap: ref.space.md
|
|
85
|
+
})),
|
|
86
|
+
errors: said(ref.error.ink),
|
|
87
|
+
summary: component(Style.self({
|
|
88
|
+
display: "grid",
|
|
89
|
+
gap: ref.space.xs,
|
|
90
|
+
padding: ref.space.md,
|
|
91
|
+
border: `${ref.border.thin} solid ${ref.error.outline}`,
|
|
92
|
+
borderRadius: ref.radius.md,
|
|
93
|
+
background: ref.error.subtle,
|
|
94
|
+
color: ref.text.default
|
|
95
|
+
})),
|
|
96
|
+
summaryTitle: component(Style.self({
|
|
97
|
+
margin: "0",
|
|
98
|
+
fontWeight: ref.weight.semibold,
|
|
99
|
+
color: ref.error.ink
|
|
100
|
+
})),
|
|
101
|
+
issues: component(Style.self({
|
|
102
|
+
margin: "0",
|
|
103
|
+
paddingInlineStart: ref.space.lg
|
|
104
|
+
})),
|
|
105
|
+
issueLink: component(Style.self({
|
|
106
|
+
color: ref.text.link,
|
|
107
|
+
textDecoration: "underline",
|
|
108
|
+
textUnderlineOffset: "3px"
|
|
109
|
+
})),
|
|
110
|
+
submit: component(button({}), Style.self({ justifySelf: "start" })),
|
|
111
|
+
group: component(Style.self({
|
|
112
|
+
display: "grid",
|
|
113
|
+
gap: ref.space.sm,
|
|
114
|
+
margin: "0",
|
|
115
|
+
padding: ref.space.md,
|
|
116
|
+
border: `${ref.border.thin} solid ${ref.outline.subtle}`,
|
|
117
|
+
borderRadius: ref.radius.md
|
|
118
|
+
})),
|
|
119
|
+
legend: component(Style.self({
|
|
120
|
+
paddingInline: ref.space["2xs"],
|
|
121
|
+
fontWeight: ref.weight.semibold
|
|
122
|
+
})),
|
|
123
|
+
row: component(Style.self({
|
|
124
|
+
display: "grid",
|
|
125
|
+
gap: ref.space.sm
|
|
126
|
+
})),
|
|
127
|
+
add: small,
|
|
128
|
+
remove: small
|
|
129
|
+
} });
|
|
130
|
+
export { Field, Form };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=recipes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipes.mjs","names":[],"sources":["../src/recipes.ts"],"sourcesContent":["/**\n * Looks for the form view's Slots over the shipped tokens, from\n * `foldkit-mixins-form/recipes`: `Style.forSlots(FieldSlots)(Field({}))` and\n * `Style.forSlots(FormSlots)(Form({}))`. Text, number, select and the relation\n * picker's search box take `foldkit-mixins-ui`'s own field looks, so a form drawn\n * with the plain renderers and one drawn with `UiForm.renderers` look the same.\n */\nimport { Layers, Style, type StyleValue } from 'foldkit-mixins'\nimport { Theme } from 'foldkit-mixins/theme'\nimport { Recipes } from 'foldkit-mixins-ui'\nimport { FieldSlots, FormSlots } from './index.js'\n\nconst ref = Theme.ref(Theme.standard())\nconst component = (...pieces: ReadonlyArray<StyleValue>): StyleValue =>\n Layers.standard.in('components', Style.compose(...pieces))\n\nconst input = Recipes.Input({}).input ?? Style.empty\nconst button = (options: Parameters<typeof Recipes.Button>[0]) =>\n Recipes.Button(options).button ?? Style.empty\n/** A small button that keeps its own width in a field or form that stretches its parts. */\nconst small = component(\n button({ tone: 'neutral', variant: 'outline', size: 'sm' }),\n Style.self({ justifySelf: 'start' }),\n)\n/** A checkbox the browser draws, a size to see and in the accent. */\nconst box = component(\n Style.self({\n inlineSize: '1rem',\n blockSize: '1rem',\n margin: '0',\n accentColor: ref.accent.default,\n }),\n)\n/** A line the field says under its control. */\nconst said = (color: string) => component(Style.self({ margin: '0', fontSize: ref.size.sm, color }))\n\n/**\n * A field: its label over its control, then what it says about it, in a grid,\n * which stretches a control with no width of its own and leaves a checkbox its\n * size. A failure reads in the error's ink; a choice of many is a row a finger's\n * height, its box beside its words.\n */\nexport const Field = Style.recipeFor(FieldSlots)({\n base: {\n root: component(Style.self({ display: 'grid', gap: ref.space['2xs'] })),\n label: component(\n Style.self({ fontSize: ref.size.sm, fontWeight: ref.weight.medium, color: ref.text.overt }),\n ),\n description: said(ref.text.muted),\n checking: said(ref.text.muted),\n error: said(ref.error.ink),\n text: input,\n number: input,\n multiline: Recipes.Textarea({}).textarea ?? Style.empty,\n select: Recipes.Select({}).select ?? Style.empty,\n toggle: box,\n choices: component(Style.self({ display: 'grid', gap: ref.space['3xs'] })),\n choiceLabel: component(\n Style.self({\n display: 'flex',\n alignItems: 'center',\n gap: ref.space.xs,\n minBlockSize: '1.5rem',\n }),\n ),\n choice: box,\n group: Recipes.InputGroup.group,\n affix: Recipes.InputGroup.affix,\n search: input,\n more: small,\n },\n})\n\n/**\n * A form: its fields in a column, a failure that is no one field's in the error's\n * ink, the list of fields to fix in a box of the error's colours, and the submit\n * as the page's primary button, as wide as its words.\n */\nexport const Form = Style.recipeFor(FormSlots)({\n base: {\n root: component(Style.self({ display: 'grid', gap: ref.space.md })),\n errors: said(ref.error.ink),\n summary: component(\n Style.self({\n display: 'grid',\n gap: ref.space.xs,\n padding: ref.space.md,\n border: `${ref.border.thin} solid ${ref.error.outline}`,\n borderRadius: ref.radius.md,\n background: ref.error.subtle,\n color: ref.text.default,\n }),\n ),\n summaryTitle: component(\n Style.self({ margin: '0', fontWeight: ref.weight.semibold, color: ref.error.ink }),\n ),\n issues: component(Style.self({ margin: '0', paddingInlineStart: ref.space.lg })),\n issueLink: component(\n Style.self({ color: ref.text.link, textDecoration: 'underline', textUnderlineOffset: '3px' }),\n ),\n submit: component(button({}), Style.self({ justifySelf: 'start' })),\n group: component(\n Style.self({\n display: 'grid',\n gap: ref.space.sm,\n margin: '0',\n padding: ref.space.md,\n border: `${ref.border.thin} solid ${ref.outline.subtle}`,\n borderRadius: ref.radius.md,\n }),\n ),\n legend: component(\n Style.self({ paddingInline: ref.space['2xs'], fontWeight: ref.weight.semibold }),\n ),\n row: component(Style.self({ display: 'grid', gap: ref.space.sm })),\n add: small,\n remove: small,\n },\n})\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-mixins-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "A foldkit-form form drawn through foldkit-mixins slots: styleable, extensible, and accessible by contract.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"types": "./dist/ui.d.mts",
|
|
33
33
|
"import": "./dist/ui.mjs"
|
|
34
34
|
},
|
|
35
|
+
"./recipes": {
|
|
36
|
+
"foldkit-plus:source": "./src/recipes.ts",
|
|
37
|
+
"types": "./dist/recipes.d.mts",
|
|
38
|
+
"import": "./dist/recipes.mjs"
|
|
39
|
+
},
|
|
35
40
|
".": {
|
|
36
41
|
"foldkit-plus:source": "./src/index.ts",
|
|
37
42
|
"types": "./dist/index.d.mts",
|
|
@@ -45,13 +50,13 @@
|
|
|
45
50
|
],
|
|
46
51
|
"dependencies": {
|
|
47
52
|
"foldkit-bundle": "0.8.1",
|
|
48
|
-
"foldkit-
|
|
49
|
-
"foldkit-
|
|
53
|
+
"foldkit-form": "0.8.1",
|
|
54
|
+
"foldkit-mixins": "0.20.0"
|
|
50
55
|
},
|
|
51
56
|
"peerDependencies": {
|
|
52
57
|
"effect": "^4.0.0",
|
|
53
58
|
"foldkit": "^0.169.0",
|
|
54
|
-
"foldkit-mixins-ui": "0.
|
|
59
|
+
"foldkit-mixins-ui": "0.21.0"
|
|
55
60
|
},
|
|
56
61
|
"peerDependenciesMeta": {
|
|
57
62
|
"foldkit-mixins-ui": {
|
|
@@ -65,8 +70,8 @@
|
|
|
65
70
|
"jsdom": "30.1.3",
|
|
66
71
|
"tsdown": "^0.23.1",
|
|
67
72
|
"typescript": "7.0.2",
|
|
68
|
-
"foldkit-
|
|
69
|
-
"foldkit-
|
|
73
|
+
"foldkit-entity": "0.13.0",
|
|
74
|
+
"foldkit-mixins-ui": "0.21.0"
|
|
70
75
|
},
|
|
71
76
|
"scripts": {
|
|
72
77
|
"build": "tsdown",
|