magic-pill 9.0.0 → 9.1.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/CHANGELOG.md +50 -0
- package/README.md +259 -15
- package/dist/MagicPill/MagicPill.d.mts +7 -1
- package/dist/MagicPill/MagicPill.d.ts +7 -1
- package/dist/MagicPill/MagicPill.js +40 -17
- package/dist/MagicPill/MagicPill.mjs +42 -19
- package/dist/MagicPill/choreography.js +1 -1
- package/dist/MagicPill/choreography.mjs +1 -1
- package/dist/Pill/Pill.js +53 -17
- package/dist/Pill/Pill.mjs +54 -18
- package/dist/Pill/PillContext.js +3 -1
- package/dist/Pill/PillContext.mjs +3 -1
- package/dist/Pill/PillPanel.d.mts +5 -5
- package/dist/Pill/PillPanel.d.ts +5 -5
- package/dist/Pill/PillPanel.js +28 -20
- package/dist/Pill/PillPanel.mjs +28 -20
- package/dist/Pill/morph.js +25 -7
- package/dist/Pill/morph.mjs +22 -8
- package/dist/Pill/scene.js +90 -0
- package/dist/Pill/scene.mjs +89 -0
- package/dist/Pill/themed.js +36 -0
- package/dist/Pill/themed.mjs +34 -0
- package/dist/Pill/types.d.mts +50 -0
- package/dist/Pill/types.d.ts +50 -0
- package/dist/Pill/zone.js +160 -0
- package/dist/Pill/zone.mjs +159 -0
- package/dist/PillForm/Calendar.d.mts +15 -0
- package/dist/PillForm/Calendar.d.ts +16 -0
- package/dist/PillForm/Calendar.js +371 -0
- package/dist/PillForm/Calendar.mjs +370 -0
- package/dist/PillForm/FormContext.d.mts +2 -0
- package/dist/PillForm/FormContext.d.ts +2 -0
- package/dist/PillForm/FormContext.js +8 -0
- package/dist/PillForm/FormContext.mjs +8 -0
- package/dist/PillForm/PillCheckbox.d.mts +8 -0
- package/dist/PillForm/PillCheckbox.d.ts +8 -0
- package/dist/PillForm/PillCheckbox.js +45 -0
- package/dist/PillForm/PillCheckbox.mjs +45 -0
- package/dist/PillForm/PillChoices.d.mts +39 -0
- package/dist/PillForm/PillChoices.d.ts +39 -0
- package/dist/PillForm/PillChoices.js +103 -0
- package/dist/PillForm/PillChoices.mjs +103 -0
- package/dist/PillForm/PillCode.d.mts +12 -0
- package/dist/PillForm/PillCode.d.ts +12 -0
- package/dist/PillForm/PillCode.js +60 -0
- package/dist/PillForm/PillCode.mjs +60 -0
- package/dist/PillForm/PillColor.d.mts +10 -0
- package/dist/PillForm/PillColor.d.ts +10 -0
- package/dist/PillForm/PillColor.js +56 -0
- package/dist/PillForm/PillColor.mjs +56 -0
- package/dist/PillForm/PillDate.d.mts +44 -0
- package/dist/PillForm/PillDate.d.ts +44 -0
- package/dist/PillForm/PillDate.js +193 -0
- package/dist/PillForm/PillDate.mjs +193 -0
- package/dist/PillForm/PillField.d.mts +38 -0
- package/dist/PillForm/PillField.d.ts +38 -0
- package/dist/PillForm/PillField.js +81 -0
- package/dist/PillForm/PillField.mjs +80 -0
- package/dist/PillForm/PillFields.d.mts +11 -0
- package/dist/PillForm/PillFields.d.ts +11 -0
- package/dist/PillForm/PillFields.js +21 -0
- package/dist/PillForm/PillFields.mjs +21 -0
- package/dist/PillForm/PillFile.d.mts +8 -0
- package/dist/PillForm/PillFile.d.ts +8 -0
- package/dist/PillForm/PillFile.js +55 -0
- package/dist/PillForm/PillFile.mjs +55 -0
- package/dist/PillForm/PillForm.d.mts +29 -0
- package/dist/PillForm/PillForm.d.ts +29 -0
- package/dist/PillForm/PillForm.js +66 -0
- package/dist/PillForm/PillForm.mjs +65 -0
- package/dist/PillForm/PillFormPanel.d.mts +24 -0
- package/dist/PillForm/PillFormPanel.d.ts +24 -0
- package/dist/PillForm/PillFormPanel.js +53 -0
- package/dist/PillForm/PillFormPanel.mjs +53 -0
- package/dist/PillForm/PillInput.d.mts +20 -0
- package/dist/PillForm/PillInput.d.ts +20 -0
- package/dist/PillForm/PillInput.js +84 -0
- package/dist/PillForm/PillInput.mjs +84 -0
- package/dist/PillForm/PillSelect.d.mts +23 -0
- package/dist/PillForm/PillSelect.d.ts +23 -0
- package/dist/PillForm/PillSelect.js +87 -0
- package/dist/PillForm/PillSelect.mjs +87 -0
- package/dist/PillForm/PillSlider.d.mts +17 -0
- package/dist/PillForm/PillSlider.d.ts +17 -0
- package/dist/PillForm/PillSlider.js +61 -0
- package/dist/PillForm/PillSlider.mjs +61 -0
- package/dist/PillForm/PillStepper.d.mts +13 -0
- package/dist/PillForm/PillStepper.d.ts +13 -0
- package/dist/PillForm/PillStepper.js +84 -0
- package/dist/PillForm/PillStepper.mjs +84 -0
- package/dist/PillForm/PillSubmit.d.mts +14 -0
- package/dist/PillForm/PillSubmit.d.ts +14 -0
- package/dist/PillForm/PillSubmit.js +90 -0
- package/dist/PillForm/PillSubmit.mjs +89 -0
- package/dist/PillForm/PillSwitch.d.mts +5 -0
- package/dist/PillForm/PillSwitch.d.ts +5 -0
- package/dist/PillForm/PillSwitch.js +38 -0
- package/dist/PillForm/PillSwitch.mjs +38 -0
- package/dist/PillForm/PillTextarea.d.mts +5 -0
- package/dist/PillForm/PillTextarea.d.ts +5 -0
- package/dist/PillForm/PillTextarea.js +49 -0
- package/dist/PillForm/PillTextarea.mjs +49 -0
- package/dist/PillForm/dates.d.mts +1 -0
- package/dist/PillForm/dates.d.ts +1 -0
- package/dist/PillForm/dates.js +155 -0
- package/dist/PillForm/dates.mjs +139 -0
- package/dist/PillForm/glyphs.js +65 -0
- package/dist/PillForm/glyphs.mjs +56 -0
- package/dist/PillForm/keyboard.js +34 -0
- package/dist/PillForm/keyboard.mjs +34 -0
- package/dist/PillForm/popover.js +84 -0
- package/dist/PillForm/popover.mjs +83 -0
- package/dist/PillForm/send.d.mts +6 -0
- package/dist/PillForm/send.d.ts +6 -0
- package/dist/PillForm/send.js +44 -0
- package/dist/PillForm/send.mjs +44 -0
- package/dist/PillForm/validity.js +74 -0
- package/dist/PillForm/validity.mjs +72 -0
- package/dist/PillNavbar/PillNavbar.d.mts +29 -6
- package/dist/PillNavbar/PillNavbar.d.ts +29 -6
- package/dist/PillNavbar/PillNavbar.js +35 -11
- package/dist/PillNavbar/PillNavbar.mjs +36 -12
- package/dist/PillNavbar/room.js +84 -0
- package/dist/PillNavbar/room.mjs +83 -0
- package/dist/PillNotification/PillNotification.d.mts +6 -0
- package/dist/PillNotification/PillNotification.d.ts +6 -0
- package/dist/PillNotification/PillNotification.js +3 -0
- package/dist/PillNotification/PillNotification.mjs +3 -0
- package/dist/PillOptics/PillOptics.d.mts +8 -0
- package/dist/PillOptics/PillOptics.d.ts +8 -0
- package/dist/PillOptics/PillOptics.js +195 -0
- package/dist/PillOptics/PillOptics.mjs +195 -0
- package/dist/PillOptics/adaptive.js +212 -0
- package/dist/PillOptics/adaptive.mjs +208 -0
- package/dist/PillOptics/lens.js +77 -0
- package/dist/PillOptics/lens.mjs +73 -0
- package/dist/PillOptics/light.js +37 -0
- package/dist/PillOptics/light.mjs +36 -0
- package/dist/calendar.css +499 -0
- package/dist/forms.css +1454 -0
- package/dist/index.d.mts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +36 -0
- package/dist/index.mjs +19 -1
- package/dist/styles.css +169 -19
- package/dist/themes.css +449 -0
- package/dist/utils/visuallyHidden.js +18 -0
- package/dist/utils/visuallyHidden.mjs +18 -0
- package/package.json +4 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
// src/PillForm/PillFields.tsx
|
|
5
|
+
/** Fields that go together. */
|
|
6
|
+
const PillFields = forwardRef(function PillFields({ label, columns = 1, separators = false, children, ...rest }, ref) {
|
|
7
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
8
|
+
role: label ? void 0 : "none",
|
|
9
|
+
...rest,
|
|
10
|
+
ref,
|
|
11
|
+
"data-mp": "fields",
|
|
12
|
+
"data-columns": columns,
|
|
13
|
+
"data-separators": separators ? "" : void 0,
|
|
14
|
+
children: [label && /* @__PURE__ */ jsx("legend", {
|
|
15
|
+
"data-mp": "fields-label",
|
|
16
|
+
children: label
|
|
17
|
+
}), /* @__PURE__ */ jsx("div", { children })]
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { PillFields };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { FieldProps } from "./PillField.mjs";
|
|
3
|
+
export interface PillFileProps extends FieldProps, Omit<ComponentPropsWithoutRef<"input">, "type" | "children" | "value" | "defaultValue"> {
|
|
4
|
+
/** What the area says while it's empty. Default "Choose a file or drop it here". */
|
|
5
|
+
prompt?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/** One or more files: an area to click or to drop them on, which names them. */
|
|
8
|
+
export declare const PillFile: import("react").ForwardRefExoticComponent<PillFileProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { FieldProps } from "./PillField.js";
|
|
3
|
+
export interface PillFileProps extends FieldProps, Omit<ComponentPropsWithoutRef<"input">, "type" | "children" | "value" | "defaultValue"> {
|
|
4
|
+
/** What the area says while it's empty. Default "Choose a file or drop it here". */
|
|
5
|
+
prompt?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/** One or more files: an area to click or to drop them on, which names them. */
|
|
8
|
+
export declare const PillFile: import("react").ForwardRefExoticComponent<PillFileProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
let react = require("react");
|
|
4
|
+
const require_PillField = require("./PillField.js");
|
|
5
|
+
const require_glyphs = require("./glyphs.js");
|
|
6
|
+
const require_validity = require("./validity.js");
|
|
7
|
+
const require_react = require("../utils/react.js");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
|
|
10
|
+
// src/PillForm/PillFile.tsx
|
|
11
|
+
/** One or more files: an area to click or to drop them on, which names them. */
|
|
12
|
+
const PillFile = (0, react.forwardRef)(function PillFile({ label, hideLabel, hint, error, optional, prompt = "Choose a file or drop it here", className, onInput, onChange, onInvalid, ...rest }, forwardedRef) {
|
|
13
|
+
const inputRef = (0, react.useRef)(null);
|
|
14
|
+
const ref = (0, react.useMemo)(() => require_react.mergeRefs(inputRef, forwardedRef), [forwardedRef]);
|
|
15
|
+
const validity = require_validity.useValidity(error, inputRef);
|
|
16
|
+
const [names, setNames] = (0, react.useState)([]);
|
|
17
|
+
const [isOver, setIsOver] = (0, react.useState)(false);
|
|
18
|
+
const read = () => setNames([...inputRef.current?.files ?? []].map((file) => file.name));
|
|
19
|
+
require_validity.useFormReset(inputRef, read);
|
|
20
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillField.FieldShell, {
|
|
21
|
+
label,
|
|
22
|
+
hideLabel,
|
|
23
|
+
hint,
|
|
24
|
+
optional,
|
|
25
|
+
className,
|
|
26
|
+
error: validity.error,
|
|
27
|
+
"data-kind": "file",
|
|
28
|
+
children: (control) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
29
|
+
"data-mp": "field-control",
|
|
30
|
+
"data-type": "file",
|
|
31
|
+
"data-over": isOver ? "" : void 0,
|
|
32
|
+
onDragEnter: () => setIsOver(true),
|
|
33
|
+
onDragLeave: () => setIsOver(false),
|
|
34
|
+
onDrop: () => setIsOver(false),
|
|
35
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
36
|
+
...rest,
|
|
37
|
+
...control,
|
|
38
|
+
ref,
|
|
39
|
+
type: "file",
|
|
40
|
+
onInput: require_validity.both(validity.handlers.onInput, onInput),
|
|
41
|
+
onChange: require_validity.both(read, onChange),
|
|
42
|
+
onInvalid: require_validity.both(validity.handlers.onInvalid, onInvalid)
|
|
43
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
44
|
+
"data-mp": "file-body",
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
47
|
+
"data-mp": "field-icon",
|
|
48
|
+
children: names.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_glyphs.TickGlyph, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_glyphs.UploadGlyph, {})
|
|
49
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: names.length > 0 ? names.join(", ") : prompt })]
|
|
50
|
+
})]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
exports.PillFile = PillFile;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { FieldShell } from "./PillField.mjs";
|
|
5
|
+
import { TickGlyph, UploadGlyph } from "./glyphs.mjs";
|
|
6
|
+
import { both, useFormReset, useValidity } from "./validity.mjs";
|
|
7
|
+
import { mergeRefs } from "../utils/react.mjs";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
// src/PillForm/PillFile.tsx
|
|
11
|
+
/** One or more files: an area to click or to drop them on, which names them. */
|
|
12
|
+
const PillFile = forwardRef(function PillFile({ label, hideLabel, hint, error, optional, prompt = "Choose a file or drop it here", className, onInput, onChange, onInvalid, ...rest }, forwardedRef) {
|
|
13
|
+
const inputRef = useRef(null);
|
|
14
|
+
const ref = useMemo(() => mergeRefs(inputRef, forwardedRef), [forwardedRef]);
|
|
15
|
+
const validity = useValidity(error, inputRef);
|
|
16
|
+
const [names, setNames] = useState([]);
|
|
17
|
+
const [isOver, setIsOver] = useState(false);
|
|
18
|
+
const read = () => setNames([...inputRef.current?.files ?? []].map((file) => file.name));
|
|
19
|
+
useFormReset(inputRef, read);
|
|
20
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
21
|
+
label,
|
|
22
|
+
hideLabel,
|
|
23
|
+
hint,
|
|
24
|
+
optional,
|
|
25
|
+
className,
|
|
26
|
+
error: validity.error,
|
|
27
|
+
"data-kind": "file",
|
|
28
|
+
children: (control) => /* @__PURE__ */ jsxs("div", {
|
|
29
|
+
"data-mp": "field-control",
|
|
30
|
+
"data-type": "file",
|
|
31
|
+
"data-over": isOver ? "" : void 0,
|
|
32
|
+
onDragEnter: () => setIsOver(true),
|
|
33
|
+
onDragLeave: () => setIsOver(false),
|
|
34
|
+
onDrop: () => setIsOver(false),
|
|
35
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
36
|
+
...rest,
|
|
37
|
+
...control,
|
|
38
|
+
ref,
|
|
39
|
+
type: "file",
|
|
40
|
+
onInput: both(validity.handlers.onInput, onInput),
|
|
41
|
+
onChange: both(read, onChange),
|
|
42
|
+
onInvalid: both(validity.handlers.onInvalid, onInvalid)
|
|
43
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
44
|
+
"data-mp": "file-body",
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
47
|
+
"data-mp": "field-icon",
|
|
48
|
+
children: names.length > 0 ? /* @__PURE__ */ jsx(TickGlyph, {}) : /* @__PURE__ */ jsx(UploadGlyph, {})
|
|
49
|
+
}), /* @__PURE__ */ jsx("span", { children: names.length > 0 ? names.join(", ") : prompt })]
|
|
50
|
+
})]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export { PillFile };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { SendHandler } from "./send.mjs";
|
|
3
|
+
import { FieldLayout, FormErrors } from "./FormContext.mjs";
|
|
4
|
+
export interface PillFormProps extends ComponentPropsWithoutRef<"form"> {
|
|
5
|
+
/**
|
|
6
|
+
* How its fields look, switches and choices included: filled like the actions (`solid`, the default), with a
|
|
7
|
+
* hint of the pill's text (`soft`), or an `outline`. Any other string is
|
|
8
|
+
* written to `data-look`, for one of your own.
|
|
9
|
+
*/
|
|
10
|
+
look?: "solid" | "soft" | "outline" | (string & {});
|
|
11
|
+
/** The label of its text fields, above (default) or beside them. */
|
|
12
|
+
layout?: FieldLayout;
|
|
13
|
+
/** The browser's validation messages, under the fields (default) or in its own bubbles. */
|
|
14
|
+
errors?: FormErrors;
|
|
15
|
+
/** Disables every field. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** The same, while something is being sent. `onSend` does it for you. */
|
|
18
|
+
busy?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Instead of `onSubmit`: called with the form's data once every field is
|
|
21
|
+
* valid, with no page load. While the promise it returns is pending, the form
|
|
22
|
+
* is busy; if it's rejected, the error's message shows under the fields.
|
|
23
|
+
*/
|
|
24
|
+
onSend?: SendHandler;
|
|
25
|
+
/** Shown when that error has no message. Default "Something went wrong." */
|
|
26
|
+
errorLabel?: string;
|
|
27
|
+
}
|
|
28
|
+
/** A form: its fields stacked in a panel, in a row in the pill itself. */
|
|
29
|
+
export declare const PillForm: import("react").ForwardRefExoticComponent<PillFormProps & import("react").RefAttributes<HTMLFormElement>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { SendHandler } from "./send.js";
|
|
3
|
+
import { FieldLayout, FormErrors } from "./FormContext.js";
|
|
4
|
+
export interface PillFormProps extends ComponentPropsWithoutRef<"form"> {
|
|
5
|
+
/**
|
|
6
|
+
* How its fields look, switches and choices included: filled like the actions (`solid`, the default), with a
|
|
7
|
+
* hint of the pill's text (`soft`), or an `outline`. Any other string is
|
|
8
|
+
* written to `data-look`, for one of your own.
|
|
9
|
+
*/
|
|
10
|
+
look?: "solid" | "soft" | "outline" | (string & {});
|
|
11
|
+
/** The label of its text fields, above (default) or beside them. */
|
|
12
|
+
layout?: FieldLayout;
|
|
13
|
+
/** The browser's validation messages, under the fields (default) or in its own bubbles. */
|
|
14
|
+
errors?: FormErrors;
|
|
15
|
+
/** Disables every field. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** The same, while something is being sent. `onSend` does it for you. */
|
|
18
|
+
busy?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Instead of `onSubmit`: called with the form's data once every field is
|
|
21
|
+
* valid, with no page load. While the promise it returns is pending, the form
|
|
22
|
+
* is busy; if it's rejected, the error's message shows under the fields.
|
|
23
|
+
*/
|
|
24
|
+
onSend?: SendHandler;
|
|
25
|
+
/** Shown when that error has no message. Default "Something went wrong." */
|
|
26
|
+
errorLabel?: string;
|
|
27
|
+
}
|
|
28
|
+
/** A form: its fields stacked in a panel, in a row in the pill itself. */
|
|
29
|
+
export declare const PillForm: import("react").ForwardRefExoticComponent<PillFormProps & import("react").RefAttributes<HTMLFormElement>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
let react = require("react");
|
|
4
|
+
const require_glyphs = require("./glyphs.js");
|
|
5
|
+
const require_send = require("./send.js");
|
|
6
|
+
const require_FormContext = require("./FormContext.js");
|
|
7
|
+
const require_keyboard = require("./keyboard.js");
|
|
8
|
+
const require_PillContext = require("../Pill/PillContext.js");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
|
|
11
|
+
// src/PillForm/PillForm.tsx
|
|
12
|
+
/** A form: its fields stacked in a panel, in a row in the pill itself. */
|
|
13
|
+
const PillForm = (0, react.forwardRef)(function PillForm({ look, layout, errors = "inline", disabled = false, busy = false, onSend, errorLabel = "Something went wrong.", onSubmit, onReset, children, ...rest }, ref) {
|
|
14
|
+
const { rootRef } = require_PillContext.useInternalPill("<PillForm>");
|
|
15
|
+
require_keyboard.useKeyboard(rootRef);
|
|
16
|
+
const sending = require_send.useSend(onSend, errorLabel);
|
|
17
|
+
const isBusy = busy || sending.isBusy;
|
|
18
|
+
const context = (0, react.useMemo)(() => ({
|
|
19
|
+
layout,
|
|
20
|
+
errors,
|
|
21
|
+
isBusy
|
|
22
|
+
}), [
|
|
23
|
+
layout,
|
|
24
|
+
errors,
|
|
25
|
+
isBusy
|
|
26
|
+
]);
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormContext.FormContext.Provider, {
|
|
28
|
+
value: context,
|
|
29
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
|
|
30
|
+
...rest,
|
|
31
|
+
ref,
|
|
32
|
+
"data-mp": "form",
|
|
33
|
+
"data-look": look,
|
|
34
|
+
"data-failed": sending.failure ? "" : void 0,
|
|
35
|
+
"aria-busy": isBusy || void 0,
|
|
36
|
+
onSubmit: (event) => {
|
|
37
|
+
onSubmit?.(event);
|
|
38
|
+
if (onSend && !event.defaultPrevented) sending.send(event);
|
|
39
|
+
},
|
|
40
|
+
onReset: (event) => {
|
|
41
|
+
sending.forget();
|
|
42
|
+
onReset?.(event);
|
|
43
|
+
},
|
|
44
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
|
|
45
|
+
role: "none",
|
|
46
|
+
"data-mp": "form-body",
|
|
47
|
+
disabled: disabled || isBusy,
|
|
48
|
+
children: [children, onSend && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormError, { children: sending.failure })]
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
/** What went wrong. Always there, so assistive technology hears what appears in it. */
|
|
54
|
+
function FormError({ children }) {
|
|
55
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
56
|
+
"data-mp": "form-error",
|
|
57
|
+
role: "alert",
|
|
58
|
+
children: children && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
59
|
+
"aria-hidden": "true",
|
|
60
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_glyphs.AlertGlyph, {})
|
|
61
|
+
}), children] })
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.FormError = FormError;
|
|
66
|
+
exports.PillForm = PillForm;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useMemo } from "react";
|
|
4
|
+
import { AlertGlyph } from "./glyphs.mjs";
|
|
5
|
+
import { useSend } from "./send.mjs";
|
|
6
|
+
import { FormContext } from "./FormContext.mjs";
|
|
7
|
+
import { useKeyboard } from "./keyboard.mjs";
|
|
8
|
+
import { useInternalPill } from "../Pill/PillContext.mjs";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
// src/PillForm/PillForm.tsx
|
|
12
|
+
/** A form: its fields stacked in a panel, in a row in the pill itself. */
|
|
13
|
+
const PillForm = forwardRef(function PillForm({ look, layout, errors = "inline", disabled = false, busy = false, onSend, errorLabel = "Something went wrong.", onSubmit, onReset, children, ...rest }, ref) {
|
|
14
|
+
const { rootRef } = useInternalPill("<PillForm>");
|
|
15
|
+
useKeyboard(rootRef);
|
|
16
|
+
const sending = useSend(onSend, errorLabel);
|
|
17
|
+
const isBusy = busy || sending.isBusy;
|
|
18
|
+
const context = useMemo(() => ({
|
|
19
|
+
layout,
|
|
20
|
+
errors,
|
|
21
|
+
isBusy
|
|
22
|
+
}), [
|
|
23
|
+
layout,
|
|
24
|
+
errors,
|
|
25
|
+
isBusy
|
|
26
|
+
]);
|
|
27
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, {
|
|
28
|
+
value: context,
|
|
29
|
+
children: /* @__PURE__ */ jsx("form", {
|
|
30
|
+
...rest,
|
|
31
|
+
ref,
|
|
32
|
+
"data-mp": "form",
|
|
33
|
+
"data-look": look,
|
|
34
|
+
"data-failed": sending.failure ? "" : void 0,
|
|
35
|
+
"aria-busy": isBusy || void 0,
|
|
36
|
+
onSubmit: (event) => {
|
|
37
|
+
onSubmit?.(event);
|
|
38
|
+
if (onSend && !event.defaultPrevented) sending.send(event);
|
|
39
|
+
},
|
|
40
|
+
onReset: (event) => {
|
|
41
|
+
sending.forget();
|
|
42
|
+
onReset?.(event);
|
|
43
|
+
},
|
|
44
|
+
children: /* @__PURE__ */ jsxs("fieldset", {
|
|
45
|
+
role: "none",
|
|
46
|
+
"data-mp": "form-body",
|
|
47
|
+
disabled: disabled || isBusy,
|
|
48
|
+
children: [children, onSend && /* @__PURE__ */ jsx(FormError, { children: sending.failure })]
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
/** What went wrong. Always there, so assistive technology hears what appears in it. */
|
|
54
|
+
function FormError({ children }) {
|
|
55
|
+
return /* @__PURE__ */ jsx("div", {
|
|
56
|
+
"data-mp": "form-error",
|
|
57
|
+
role: "alert",
|
|
58
|
+
children: children && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("i", {
|
|
59
|
+
"aria-hidden": "true",
|
|
60
|
+
children: /* @__PURE__ */ jsx(AlertGlyph, {})
|
|
61
|
+
}), children] })
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { FormError, PillForm };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { PillFormProps } from "./PillForm.mjs";
|
|
3
|
+
import { PillSubmitProps } from "./PillSubmit.mjs";
|
|
4
|
+
import { SendHandler } from "./send.mjs";
|
|
5
|
+
import { PillPanelProps } from "../Pill/types.mjs";
|
|
6
|
+
export interface PillFormPanelProps extends Pick<PillPanelProps, "name" | "title" | "titleAction" | "closeLabel" | "closeIcon" | "closeExpanded">, Pick<PillFormProps, "look" | "layout" | "errors" | "disabled" | "errorLabel">, Pick<PillSubmitProps, "busyLabel" | "busyInterval"> {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Called once every field is valid. The panel closes after it, unless it
|
|
10
|
+
* returns `false`. While the promise it returns is pending, the fields wait;
|
|
11
|
+
* if it's rejected, the panel stays open and shows the error's message.
|
|
12
|
+
*/
|
|
13
|
+
onSubmit?: SendHandler;
|
|
14
|
+
/** The main action, e.g. "Save". Without it there's none: settings that apply at once. */
|
|
15
|
+
submitLabel?: string;
|
|
16
|
+
/** Default <CheckIcon />. */
|
|
17
|
+
submitIcon?: ReactNode;
|
|
18
|
+
/** An action in the title's row that resets the fields, e.g. "Default". */
|
|
19
|
+
resetLabel?: string;
|
|
20
|
+
/** For the panel. */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/** A panel that is a form: it sends, waits, and closes. The ref is the form's. */
|
|
24
|
+
export declare const PillFormPanel: import("react").ForwardRefExoticComponent<PillFormPanelProps & import("react").RefAttributes<HTMLFormElement>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { PillFormProps } from "./PillForm.js";
|
|
3
|
+
import { PillSubmitProps } from "./PillSubmit.js";
|
|
4
|
+
import { SendHandler } from "./send.js";
|
|
5
|
+
import { PillPanelProps } from "../Pill/types.js";
|
|
6
|
+
export interface PillFormPanelProps extends Pick<PillPanelProps, "name" | "title" | "titleAction" | "closeLabel" | "closeIcon" | "closeExpanded">, Pick<PillFormProps, "look" | "layout" | "errors" | "disabled" | "errorLabel">, Pick<PillSubmitProps, "busyLabel" | "busyInterval"> {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Called once every field is valid. The panel closes after it, unless it
|
|
10
|
+
* returns `false`. While the promise it returns is pending, the fields wait;
|
|
11
|
+
* if it's rejected, the panel stays open and shows the error's message.
|
|
12
|
+
*/
|
|
13
|
+
onSubmit?: SendHandler;
|
|
14
|
+
/** The main action, e.g. "Save". Without it there's none: settings that apply at once. */
|
|
15
|
+
submitLabel?: string;
|
|
16
|
+
/** Default <CheckIcon />. */
|
|
17
|
+
submitIcon?: ReactNode;
|
|
18
|
+
/** An action in the title's row that resets the fields, e.g. "Default". */
|
|
19
|
+
resetLabel?: string;
|
|
20
|
+
/** For the panel. */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/** A panel that is a form: it sends, waits, and closes. The ref is the form's. */
|
|
24
|
+
export declare const PillFormPanel: import("react").ForwardRefExoticComponent<PillFormPanelProps & import("react").RefAttributes<HTMLFormElement>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
let react = require("react");
|
|
4
|
+
const require_PillForm = require("./PillForm.js");
|
|
5
|
+
const require_PillSubmit = require("./PillSubmit.js");
|
|
6
|
+
const require_send = require("./send.js");
|
|
7
|
+
const require_PillAction = require("../Pill/PillAction.js");
|
|
8
|
+
const require_PillContext = require("../Pill/PillContext.js");
|
|
9
|
+
const require_PillPanel = require("../Pill/PillPanel.js");
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
|
|
12
|
+
// src/PillForm/PillFormPanel.tsx
|
|
13
|
+
/** A panel that is a form: it sends, waits, and closes. The ref is the form's. */
|
|
14
|
+
const PillFormPanel = (0, react.forwardRef)(function PillFormPanel({ title, titleAction, children, onSubmit, submitLabel, submitIcon, busyLabel, busyInterval, resetLabel, errorLabel = "Something went wrong.", look, layout, errors, disabled, ...panel }, ref) {
|
|
15
|
+
const formId = (0, react.useId)();
|
|
16
|
+
const { presence, panel: openPanel, closePanel } = require_PillContext.useInternalPill("<PillFormPanel>");
|
|
17
|
+
const close = (0, react.useRef)(closePanel);
|
|
18
|
+
close.current = () => {
|
|
19
|
+
if (presence === "panel" && openPanel === panel.name) closePanel();
|
|
20
|
+
};
|
|
21
|
+
const { send, isBusy, failure, forget } = require_send.useSend(onSubmit, errorLabel, () => close.current());
|
|
22
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillPanel.PillPanel, {
|
|
23
|
+
...panel,
|
|
24
|
+
title,
|
|
25
|
+
titleAction: titleAction ?? (resetLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
|
|
26
|
+
type: "reset",
|
|
27
|
+
form: formId,
|
|
28
|
+
label: resetLabel
|
|
29
|
+
})),
|
|
30
|
+
footer: submitLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillSubmit.PillSubmit, {
|
|
31
|
+
form: formId,
|
|
32
|
+
icon: submitIcon,
|
|
33
|
+
label: submitLabel,
|
|
34
|
+
busy: isBusy,
|
|
35
|
+
busyLabel,
|
|
36
|
+
busyInterval
|
|
37
|
+
}),
|
|
38
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_PillForm.PillForm, {
|
|
39
|
+
ref,
|
|
40
|
+
id: formId,
|
|
41
|
+
look,
|
|
42
|
+
layout,
|
|
43
|
+
errors,
|
|
44
|
+
disabled,
|
|
45
|
+
busy: isBusy,
|
|
46
|
+
onSubmit: (event) => void send(event),
|
|
47
|
+
onReset: forget,
|
|
48
|
+
children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillForm.FormError, { children: failure })]
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
exports.PillFormPanel = PillFormPanel;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useId, useRef } from "react";
|
|
4
|
+
import { FormError, PillForm } from "./PillForm.mjs";
|
|
5
|
+
import { PillSubmit } from "./PillSubmit.mjs";
|
|
6
|
+
import { useSend } from "./send.mjs";
|
|
7
|
+
import PillAction from "../Pill/PillAction.mjs";
|
|
8
|
+
import { useInternalPill } from "../Pill/PillContext.mjs";
|
|
9
|
+
import { PillPanel } from "../Pill/PillPanel.mjs";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
// src/PillForm/PillFormPanel.tsx
|
|
13
|
+
/** A panel that is a form: it sends, waits, and closes. The ref is the form's. */
|
|
14
|
+
const PillFormPanel = forwardRef(function PillFormPanel({ title, titleAction, children, onSubmit, submitLabel, submitIcon, busyLabel, busyInterval, resetLabel, errorLabel = "Something went wrong.", look, layout, errors, disabled, ...panel }, ref) {
|
|
15
|
+
const formId = useId();
|
|
16
|
+
const { presence, panel: openPanel, closePanel } = useInternalPill("<PillFormPanel>");
|
|
17
|
+
const close = useRef(closePanel);
|
|
18
|
+
close.current = () => {
|
|
19
|
+
if (presence === "panel" && openPanel === panel.name) closePanel();
|
|
20
|
+
};
|
|
21
|
+
const { send, isBusy, failure, forget } = useSend(onSubmit, errorLabel, () => close.current());
|
|
22
|
+
return /* @__PURE__ */ jsx(PillPanel, {
|
|
23
|
+
...panel,
|
|
24
|
+
title,
|
|
25
|
+
titleAction: titleAction ?? (resetLabel && /* @__PURE__ */ jsx(PillAction, {
|
|
26
|
+
type: "reset",
|
|
27
|
+
form: formId,
|
|
28
|
+
label: resetLabel
|
|
29
|
+
})),
|
|
30
|
+
footer: submitLabel && /* @__PURE__ */ jsx(PillSubmit, {
|
|
31
|
+
form: formId,
|
|
32
|
+
icon: submitIcon,
|
|
33
|
+
label: submitLabel,
|
|
34
|
+
busy: isBusy,
|
|
35
|
+
busyLabel,
|
|
36
|
+
busyInterval
|
|
37
|
+
}),
|
|
38
|
+
children: /* @__PURE__ */ jsxs(PillForm, {
|
|
39
|
+
ref,
|
|
40
|
+
id: formId,
|
|
41
|
+
look,
|
|
42
|
+
layout,
|
|
43
|
+
errors,
|
|
44
|
+
disabled,
|
|
45
|
+
busy: isBusy,
|
|
46
|
+
onSubmit: (event) => void send(event),
|
|
47
|
+
onReset: forget,
|
|
48
|
+
children: [children, /* @__PURE__ */ jsx(FormError, { children: failure })]
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export { PillFormPanel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { FieldProps } from "./PillField.mjs";
|
|
3
|
+
import { FieldLayout } from "./FormContext.mjs";
|
|
4
|
+
export type PillInputType = "text" | "email" | "password" | "search" | "tel" | "url" | "number" | "date" | "time" | "datetime-local" | "month" | "week";
|
|
5
|
+
export interface PillInputProps extends FieldProps, Omit<ComponentPropsWithoutRef<"input">, "type" | "children"> {
|
|
6
|
+
/** Default `text`. */
|
|
7
|
+
type?: PillInputType;
|
|
8
|
+
/** The label above the control, or beside it. Default: the form's, or above. */
|
|
9
|
+
layout?: FieldLayout;
|
|
10
|
+
/** Before the text. `search` has its own. */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** After the text, e.g. a unit. */
|
|
13
|
+
suffix?: ReactNode;
|
|
14
|
+
/** A native list of suggestions. */
|
|
15
|
+
suggestions?: readonly string[];
|
|
16
|
+
/** `password` only: the name of the button that shows it. Default "Show the password". */
|
|
17
|
+
revealLabel?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A line of text, a number or a date. Any other prop goes to the native `<input>`. */
|
|
20
|
+
export declare const PillInput: import("react").ForwardRefExoticComponent<PillInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { FieldProps } from "./PillField.js";
|
|
3
|
+
import { FieldLayout } from "./FormContext.js";
|
|
4
|
+
export type PillInputType = "text" | "email" | "password" | "search" | "tel" | "url" | "number" | "date" | "time" | "datetime-local" | "month" | "week";
|
|
5
|
+
export interface PillInputProps extends FieldProps, Omit<ComponentPropsWithoutRef<"input">, "type" | "children"> {
|
|
6
|
+
/** Default `text`. */
|
|
7
|
+
type?: PillInputType;
|
|
8
|
+
/** The label above the control, or beside it. Default: the form's, or above. */
|
|
9
|
+
layout?: FieldLayout;
|
|
10
|
+
/** Before the text. `search` has its own. */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** After the text, e.g. a unit. */
|
|
13
|
+
suffix?: ReactNode;
|
|
14
|
+
/** A native list of suggestions. */
|
|
15
|
+
suggestions?: readonly string[];
|
|
16
|
+
/** `password` only: the name of the button that shows it. Default "Show the password". */
|
|
17
|
+
revealLabel?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A line of text, a number or a date. Any other prop goes to the native `<input>`. */
|
|
20
|
+
export declare const PillInput: import("react").ForwardRefExoticComponent<PillInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
let react = require("react");
|
|
4
|
+
const require_PillField = require("./PillField.js");
|
|
5
|
+
const require_validity = require("./validity.js");
|
|
6
|
+
const require_glyphs = require("./glyphs.js");
|
|
7
|
+
const require_react = require("../utils/react.js");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
|
|
10
|
+
// src/PillForm/PillInput.tsx
|
|
11
|
+
/** The sign of what the browser opens */
|
|
12
|
+
const PICKERS = {
|
|
13
|
+
date: require_glyphs.CalendarGlyph,
|
|
14
|
+
"datetime-local": require_glyphs.CalendarGlyph,
|
|
15
|
+
month: require_glyphs.CalendarGlyph,
|
|
16
|
+
week: require_glyphs.CalendarGlyph,
|
|
17
|
+
time: require_glyphs.ClockGlyph
|
|
18
|
+
};
|
|
19
|
+
/** A line of text, a number or a date. Any other prop goes to the native `<input>`. */
|
|
20
|
+
const PillInput = (0, react.forwardRef)(function PillInput({ label, hideLabel, hint, error, optional, layout, type = "text", icon, suffix, suggestions, revealLabel = "Show the password", className, onInput, onBlur, onInvalid, ...rest }, forwardedRef) {
|
|
21
|
+
const inputRef = (0, react.useRef)(null);
|
|
22
|
+
const ref = (0, react.useMemo)(() => require_react.mergeRefs(inputRef, forwardedRef), [forwardedRef]);
|
|
23
|
+
const validity = require_validity.useValidity(error, inputRef);
|
|
24
|
+
const [isRevealed, setIsRevealed] = (0, react.useState)(false);
|
|
25
|
+
const listId = (0, react.useId)();
|
|
26
|
+
const PickerGlyph = PICKERS[type];
|
|
27
|
+
const leading = icon ?? (type === "search" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_glyphs.SearchGlyph, {}) : void 0);
|
|
28
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillField.FieldShell, {
|
|
29
|
+
label,
|
|
30
|
+
hideLabel,
|
|
31
|
+
hint,
|
|
32
|
+
optional,
|
|
33
|
+
layout,
|
|
34
|
+
className,
|
|
35
|
+
error: validity.error,
|
|
36
|
+
isText: true,
|
|
37
|
+
"data-kind": "text",
|
|
38
|
+
children: (control) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
39
|
+
"data-mp": "field-box",
|
|
40
|
+
"data-type": type,
|
|
41
|
+
children: [
|
|
42
|
+
leading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
43
|
+
"data-mp": "field-icon",
|
|
44
|
+
"aria-hidden": "true",
|
|
45
|
+
children: leading
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
48
|
+
...rest,
|
|
49
|
+
...control,
|
|
50
|
+
ref,
|
|
51
|
+
type: type === "password" && isRevealed ? "text" : type,
|
|
52
|
+
list: suggestions ? listId : rest.list,
|
|
53
|
+
onInput: require_validity.both(validity.handlers.onInput, onInput),
|
|
54
|
+
onBlur: require_validity.both(validity.handlers.onBlur, onBlur),
|
|
55
|
+
onInvalid: require_validity.both(validity.handlers.onInvalid, onInvalid)
|
|
56
|
+
}),
|
|
57
|
+
suffix && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
58
|
+
"data-mp": "field-suffix",
|
|
59
|
+
children: suffix
|
|
60
|
+
}),
|
|
61
|
+
PickerGlyph && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
62
|
+
"data-mp": "field-icon",
|
|
63
|
+
"aria-hidden": "true",
|
|
64
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PickerGlyph, {})
|
|
65
|
+
}),
|
|
66
|
+
type === "password" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
"data-mp": "field-button",
|
|
69
|
+
"aria-label": revealLabel,
|
|
70
|
+
"aria-pressed": isRevealed,
|
|
71
|
+
disabled: rest.disabled,
|
|
72
|
+
onClick: () => setIsRevealed(!isRevealed),
|
|
73
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_glyphs.EyeGlyph, { crossed: isRevealed })
|
|
74
|
+
}),
|
|
75
|
+
suggestions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("datalist", {
|
|
76
|
+
id: listId,
|
|
77
|
+
children: suggestions.map((suggestion) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", { value: suggestion }, suggestion))
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
exports.PillInput = PillInput;
|