staffa 0.20.0 → 0.22.1
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 +10 -0
- package/dist/components/autocomplete.d.ts +30 -1
- package/dist/components/autocomplete.js +63 -12
- package/dist/components/dialog.d.ts +3 -2
- package/dist/components/dialog.js +33 -6
- package/dist/components/field.d.ts +38 -0
- package/dist/components/field.js +70 -0
- package/dist/components/form.js +5 -0
- package/dist/components/textarea.d.ts +31 -4
- package/dist/components/textarea.js +54 -24
- package/dist/components/textline.d.ts +5 -2
- package/dist/components/textline.js +19 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/staffa.esm.js +1 -1
- package/package.json +2 -2
- package/skill/AutocompleteOptions.md +15 -1
- package/skill/InsetOptions.md +23 -0
- package/skill/SKILL.md +26 -0
- package/skill/TextareaOptions.md +7 -2
- package/skill/autocomplete.md +4 -0
- package/skill/dialog.md +3 -2
- package/skill/matchWords.md +17 -0
- package/skill/textarea.md +18 -0
- package/skill/textline.md +3 -0
- package/src/components/autocomplete.ts +78 -12
- package/src/components/dialog.ts +33 -6
- package/src/components/field.ts +92 -0
- package/src/components/form.ts +5 -0
- package/src/components/textarea.ts +61 -22
- package/src/components/textline.ts +15 -10
- package/src/index.ts +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import A from "aberdeen";
|
|
2
2
|
import type { Bindable } from "../core.js";
|
|
3
|
-
import { type FieldOptions, applyControlAttrs, drawField } from "./field.js";
|
|
3
|
+
import { type FieldOptions, type InsetOptions, applyControlAttrs, drawField, drawInsets } from "./field.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The `<input>` types {@link textline} supports. Deliberately excludes types
|
|
@@ -22,7 +22,7 @@ export type TextlineType =
|
|
|
22
22
|
| "week";
|
|
23
23
|
|
|
24
24
|
/** Options for {@link textline}. */
|
|
25
|
-
export interface TextlineOptions extends FieldOptions {
|
|
25
|
+
export interface TextlineOptions extends FieldOptions, InsetOptions {
|
|
26
26
|
/** Input type. Defaults to `"text"`. */
|
|
27
27
|
type?: TextlineType;
|
|
28
28
|
/** Placeholder text. */
|
|
@@ -48,18 +48,23 @@ export interface TextlineOptions extends FieldOptions {
|
|
|
48
48
|
* ```ts
|
|
49
49
|
* const $user = A.proxy({email: "test@example.com"});
|
|
50
50
|
* S.textline({ label: "Email", type: "email", required: true, bind: A.ref($user, "email") });
|
|
51
|
+
*
|
|
52
|
+
* // Content inside the field: a glyph against its left edge, a button against its right.
|
|
53
|
+
* S.textline({ placeholder: "Search…", prefix: search, suffix: () => S.iconButton({ icon: x, tooltip: "Clear" }) });
|
|
51
54
|
* ```
|
|
52
55
|
*/
|
|
53
56
|
export function textline(opts: TextlineOptions = {}): void {
|
|
54
57
|
drawField(opts, (id, isInvalid) => {
|
|
55
|
-
|
|
56
|
-
A("
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
drawInsets(opts, false, () => {
|
|
59
|
+
A("input.s-input", opts.inputAttrs, () => {
|
|
60
|
+
A("type=", opts.type ?? "text");
|
|
61
|
+
if (opts.placeholder != null) A("placeholder=", opts.placeholder);
|
|
62
|
+
if (opts.autocomplete != null) A("autocomplete=", opts.autocomplete);
|
|
63
|
+
if (opts.value != null && !opts.bind) A("value=", opts.value);
|
|
64
|
+
if (opts.input) A("input=", opts.input);
|
|
65
|
+
if (opts.change) A("change=", opts.change);
|
|
66
|
+
applyControlAttrs(opts, id, isInvalid, opts.bind);
|
|
67
|
+
});
|
|
63
68
|
});
|
|
64
69
|
});
|
|
65
70
|
}
|
package/src/index.ts
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
export { setDarkMode, getDarkMode } from "./theme.js";
|
|
35
35
|
export { formatKey, bindKey } from "./keys.js";
|
|
36
36
|
export { showKeyHelp, setKeyHelp } from "./components/keyhelp.js";
|
|
37
|
-
export { autocomplete, type AutocompleteOptions, type AutocompleteOptionInput } from "./components/autocomplete.js";
|
|
37
|
+
export { autocomplete, matchWords, type AutocompleteOptions, type AutocompleteOptionInput } from "./components/autocomplete.js";
|
|
38
38
|
export { box, type BoxOptions } from "./components/box.js";
|
|
39
39
|
export { button, iconButton, type ButtonOptions, type IconButtonOptions } from "./components/button.js";
|
|
40
40
|
export { buttonChooser, type ButtonChooserOptions } from "./components/buttonChooser.js";
|
|
@@ -51,7 +51,7 @@ export { textarea, type TextareaOptions } from "./components/textarea.js";
|
|
|
51
51
|
export { textline, type TextlineOptions, type TextlineType } from "./components/textline.js";
|
|
52
52
|
export { toast, type ToastOptions } from "./components/toast.js";
|
|
53
53
|
export { addTooltip, type TooltipOptions } from "./components/tooltip.js";
|
|
54
|
-
export type { FieldOptions } from "./components/field.js";
|
|
54
|
+
export type { FieldOptions, InsetOptions } from "./components/field.js";
|
|
55
55
|
|
|
56
56
|
// Re-export theming and shared types for advanced use.
|
|
57
57
|
export type {ContentOptions, Bindable, Slot, Attributes} from "./core.js";
|