@ksojecki/purpose-ui 0.0.0-stage → 0.2.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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -2
  3. package/assets/fonts/Karla[wght].ttf +0 -0
  4. package/assets/fonts/OFL.txt +93 -0
  5. package/dist/Alert-D-5k0maf.js +23 -0
  6. package/dist/Button-T8UI5igR.js +112 -0
  7. package/dist/Dropdown-BZKzAbKB.js +56 -0
  8. package/dist/Heading-CWDWXU_n.js +27 -0
  9. package/dist/IconButton-P7nSooA3.js +18 -0
  10. package/dist/Link-9mNYgEzY.js +36 -0
  11. package/dist/Paragraph-DFwfb2Yt.js +14 -0
  12. package/dist/Switch-CI8vMkGz.js +84 -0
  13. package/dist/actions/Button.d.ts +69 -0
  14. package/dist/actions/ButtonGroup.d.ts +20 -0
  15. package/dist/actions/IconActionButtons.d.ts +34 -0
  16. package/dist/actions/IconButton.d.ts +21 -0
  17. package/dist/actions/index.d.ts +10 -0
  18. package/dist/actions/index.js +41 -0
  19. package/dist/classNames-x6JVYA2t.js +5 -0
  20. package/dist/data/DataTable.d.ts +47 -0
  21. package/dist/data/Metric.d.ts +46 -0
  22. package/dist/data/Table.d.ts +33 -0
  23. package/dist/data/index.d.ts +8 -0
  24. package/dist/data/index.js +85 -0
  25. package/dist/feedback/Alert.d.ts +23 -0
  26. package/dist/feedback/Badge.d.ts +23 -0
  27. package/dist/feedback/ConfirmDeletePanel.d.ts +32 -0
  28. package/dist/feedback/EmptyState.d.ts +22 -0
  29. package/dist/feedback/Progress.d.ts +24 -0
  30. package/dist/feedback/Skeleton.d.ts +10 -0
  31. package/dist/feedback/Spinner.d.ts +16 -0
  32. package/dist/feedback/Toast.d.ts +48 -0
  33. package/dist/feedback/Tooltip.d.ts +21 -0
  34. package/dist/feedback/index.d.ts +15 -0
  35. package/dist/feedback/index.js +138 -0
  36. package/dist/forms/Checkbox.d.ts +16 -0
  37. package/dist/forms/DatePicker.d.ts +51 -0
  38. package/dist/forms/Field.d.ts +65 -0
  39. package/dist/forms/FileInput.d.ts +20 -0
  40. package/dist/forms/FilterBar.d.ts +21 -0
  41. package/dist/forms/FilterRow.d.ts +20 -0
  42. package/dist/forms/FormActions.d.ts +28 -0
  43. package/dist/forms/FormField.d.ts +39 -0
  44. package/dist/forms/Input.d.ts +20 -0
  45. package/dist/forms/Radio.d.ts +52 -0
  46. package/dist/forms/Range.d.ts +24 -0
  47. package/dist/forms/SegmentedControl.d.ts +33 -0
  48. package/dist/forms/Select.d.ts +23 -0
  49. package/dist/forms/Switch.d.ts +15 -0
  50. package/dist/forms/Textarea.d.ts +20 -0
  51. package/dist/forms/TimePicker.d.ts +29 -0
  52. package/dist/forms/index.d.ts +21 -0
  53. package/dist/forms/index.js +429 -0
  54. package/dist/icons/index.d.ts +2 -0
  55. package/dist/icons/index.js +2 -0
  56. package/dist/icons-CMOARHwx.js +18 -0
  57. package/dist/internal/classNames.d.ts +1 -0
  58. package/dist/internal/purpose.d.ts +7 -0
  59. package/dist/layout/BottomSheet.d.ts +25 -0
  60. package/dist/layout/Card.d.ts +22 -0
  61. package/dist/layout/Disclosure.d.ts +18 -0
  62. package/dist/layout/Divider.d.ts +16 -0
  63. package/dist/layout/Page/Content.d.ts +11 -0
  64. package/dist/layout/Page/Page.d.ts +6 -0
  65. package/dist/layout/Page/index.d.ts +19 -0
  66. package/dist/layout/PageContainer.d.ts +18 -0
  67. package/dist/layout/PageHeader.d.ts +25 -0
  68. package/dist/layout/Section.d.ts +22 -0
  69. package/dist/layout/index.d.ts +13 -0
  70. package/dist/layout/index.js +173 -0
  71. package/dist/navigation/Dropdown.d.ts +47 -0
  72. package/dist/navigation/Link.d.ts +32 -0
  73. package/dist/navigation/Menu.d.ts +89 -0
  74. package/dist/navigation/NavMenu.d.ts +56 -0
  75. package/dist/navigation/index.d.ts +9 -0
  76. package/dist/navigation/index.js +128 -0
  77. package/dist/navigation/popoverFade.d.ts +5 -0
  78. package/dist/overlays/ConsentBanner/ConsentBanner.d.ts +35 -0
  79. package/dist/overlays/ConsentBanner/index.d.ts +1 -0
  80. package/dist/overlays/ConsentSettings/ConsentSettings.d.ts +48 -0
  81. package/dist/overlays/ConsentSettings/index.d.ts +1 -0
  82. package/dist/overlays/ModalWindow/ModalWindow.d.ts +60 -0
  83. package/dist/overlays/ModalWindow/index.d.ts +3 -0
  84. package/dist/overlays/index.d.ts +8 -0
  85. package/dist/overlays/index.js +195 -0
  86. package/dist/typography/Heading/Heading.d.ts +24 -0
  87. package/dist/typography/Heading/index.d.ts +1 -0
  88. package/dist/typography/Paragraph.d.ts +16 -0
  89. package/dist/typography/Prose.d.ts +17 -0
  90. package/dist/typography/index.d.ts +8 -0
  91. package/dist/typography/index.js +12 -0
  92. package/package.json +121 -4
  93. package/styles/budget.css +9 -0
  94. package/styles/generic.css +9 -0
  95. package/styles/roadsign.css +9 -0
  96. package/styles/traffic.css +9 -0
  97. package/theme.css +341 -0
  98. package/themes/budget.css +103 -0
  99. package/themes/generic.css +103 -0
  100. package/themes/roadsign.css +103 -0
  101. package/themes/traffic.css +103 -0
@@ -0,0 +1,138 @@
1
+ import { t as e } from "../Alert-D-5k0maf.js";
2
+ import { t } from "../classNames-x6JVYA2t.js";
3
+ import { t as n } from "../IconButton-P7nSooA3.js";
4
+ import { t as r } from "../icons-CMOARHwx.js";
5
+ import { o as i } from "../Button-T8UI5igR.js";
6
+ import { DeleteButton as a } from "../actions/index.js";
7
+ import { t as o } from "../Heading-CWDWXU_n.js";
8
+ import { cloneElement as s, useId as c } from "react";
9
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
10
+ // src/feedback/Badge.tsx
11
+ var d = {
12
+ neutral: "badge-neutral",
13
+ info: "badge-info",
14
+ success: "badge-success",
15
+ warning: "badge-warning",
16
+ error: "badge-error"
17
+ }, f = {
18
+ solid: "",
19
+ soft: "badge-soft",
20
+ outline: "badge-outline"
21
+ }, p = {
22
+ xs: "badge-xs",
23
+ sm: "badge-sm",
24
+ md: "",
25
+ lg: "badge-lg"
26
+ }, m = ({ children: e, className: n, purpose: r = "neutral", size: i = "md", variant: a = "soft", ...o }) => /* @__PURE__ */ l("span", {
27
+ className: t("badge", d[r], f[a], p[i], n),
28
+ ...o,
29
+ children: e
30
+ }), h = {
31
+ "top-end": "toast-top toast-end",
32
+ "bottom-end": "toast-bottom toast-end",
33
+ "bottom-center": "toast-bottom toast-center"
34
+ }, g = ({ children: e, className: n, position: r = "bottom-end" }) => /* @__PURE__ */ l("output", {
35
+ className: t("toast", h[r], n),
36
+ children: e
37
+ }), _ = ({ children: t, dismissLabel: i, onDismiss: a, purpose: o = "info" }) => /* @__PURE__ */ u(e, {
38
+ announce: o === "warning" || o === "error",
39
+ className: "justify-between",
40
+ purpose: o,
41
+ children: [/* @__PURE__ */ l("span", { children: t }), a && i !== void 0 ? /* @__PURE__ */ l(n, {
42
+ icon: /* @__PURE__ */ l(r.TbX, {}),
43
+ label: i,
44
+ onClick: a,
45
+ size: "xs",
46
+ tone: "ghost"
47
+ }) : null]
48
+ }), v = {
49
+ neutral: "progress-neutral",
50
+ info: "progress-info",
51
+ success: "progress-success",
52
+ warning: "progress-warning",
53
+ error: "progress-error"
54
+ }, y = (e, t) => Math.min(Math.max(e, 0), t), b = ({ className: e, label: n, marker: r, max: i = 100, purpose: a = "neutral", value: o, ...s }) => {
55
+ let c = /* @__PURE__ */ l("progress", {
56
+ ...s,
57
+ "aria-label": n,
58
+ className: t("progress", v[a], e),
59
+ max: i,
60
+ value: y(o, i)
61
+ });
62
+ if (r === void 0) return c;
63
+ let d = i > 0 ? y(r, i) / i * 100 : 0;
64
+ return /* @__PURE__ */ u("div", {
65
+ className: "relative flex",
66
+ children: [c, /* @__PURE__ */ l("span", {
67
+ "aria-hidden": "true",
68
+ className: "pointer-events-none absolute top-1/2 h-4 w-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-base-content",
69
+ style: { left: `${d}%` }
70
+ })]
71
+ });
72
+ }, x = ({ className: e, ...n }) => /* @__PURE__ */ l("div", {
73
+ ...n,
74
+ "aria-hidden": "true",
75
+ className: t("skeleton", e)
76
+ }), S = {
77
+ top: "tooltip-top",
78
+ bottom: "tooltip-bottom",
79
+ left: "tooltip-left",
80
+ right: "tooltip-right"
81
+ }, C = ({ children: e, className: n, position: r = "top", text: i, ...a }) => {
82
+ let o = c(), d = [e.props["aria-describedby"], o].filter(Boolean).join(" ");
83
+ return /* @__PURE__ */ u("span", {
84
+ ...a,
85
+ className: t("tooltip", S[r], n),
86
+ "data-tip": i,
87
+ children: [s(e, { "aria-describedby": d }), /* @__PURE__ */ l("span", {
88
+ className: "sr-only",
89
+ id: o,
90
+ children: i
91
+ })]
92
+ });
93
+ }, w = ({ cancelLabel: i, children: o, className: s, confirmLabel: c, error: d, onCancel: f, onConfirm: p, saving: m = !1, warning: h }) => /* @__PURE__ */ u("div", {
94
+ className: t("space-y-3", s),
95
+ children: [
96
+ o,
97
+ h ? /* @__PURE__ */ l(e, {
98
+ announce: !1,
99
+ purpose: "warning",
100
+ children: h
101
+ }) : null,
102
+ d ? /* @__PURE__ */ l(e, {
103
+ purpose: "error",
104
+ children: d
105
+ }) : null,
106
+ /* @__PURE__ */ u("div", {
107
+ className: "flex justify-end gap-2",
108
+ children: [/* @__PURE__ */ l(n, {
109
+ disabled: m,
110
+ icon: /* @__PURE__ */ l(r.TbX, {}),
111
+ label: i,
112
+ onClick: f,
113
+ size: "sm"
114
+ }), /* @__PURE__ */ l(a, {
115
+ disabled: m,
116
+ label: c,
117
+ onClick: p,
118
+ size: "sm"
119
+ })]
120
+ })
121
+ ]
122
+ }), T = ({ action: e, children: n, className: r, size: i = "md", title: a }) => /* @__PURE__ */ u("div", {
123
+ className: t("rounded-box border border-dashed border-base-300 text-center text-base-content/60", i === "sm" ? "p-4 text-sm" : "p-8", r),
124
+ children: [
125
+ a ? /* @__PURE__ */ l(o, {
126
+ className: "mb-1 font-semibold text-base-content",
127
+ level: 3,
128
+ size: 4,
129
+ children: a
130
+ }) : null,
131
+ n,
132
+ e ? /* @__PURE__ */ l("div", {
133
+ className: "mt-4",
134
+ children: e
135
+ }) : null
136
+ ]
137
+ });
138
+ export { e as Alert, m as Badge, w as ConfirmDeletePanel, T as EmptyState, b as Progress, x as Skeleton, i as Spinner, _ as Toast, g as ToastRegion, C as Tooltip };
@@ -0,0 +1,16 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import { type ControlSize } from './Field';
3
+ export interface CheckboxProps extends Omit<ComponentPropsWithRef<'input'>, 'size' | 'type'> {
4
+ label: string;
5
+ error?: string;
6
+ controlSize?: ControlSize;
7
+ }
8
+ /**
9
+ * Shared checkbox with its label wrapped around it.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * <Checkbox defaultChecked label="Remember me" />
14
+ * ```
15
+ */
16
+ export declare function Checkbox({ label, error, controlSize, className, id, 'aria-describedby': callerDescribedBy, ...props }: CheckboxProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { type DetailedHTMLProps, type HTMLAttributes } from 'react';
2
+ type CallyElement<T = object> = DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & T;
3
+ interface CalendarDateElement extends HTMLElement {
4
+ value: string;
5
+ }
6
+ declare module 'react' {
7
+ namespace JSX {
8
+ interface IntrinsicElements {
9
+ 'calendar-date': CallyElement<{
10
+ class?: string;
11
+ locale?: string;
12
+ min?: string;
13
+ max?: string;
14
+ onchange?: (event: Event & {
15
+ target: CalendarDateElement;
16
+ }) => void;
17
+ value?: string;
18
+ }>;
19
+ 'calendar-month': CallyElement;
20
+ }
21
+ }
22
+ }
23
+ interface DatePickerProps {
24
+ id: string;
25
+ min?: string;
26
+ max?: string;
27
+ disabled?: boolean;
28
+ /** BCP 47 tag for the trigger text and the calendar. */
29
+ locale: string;
30
+ previousLabel: string;
31
+ nextLabel: string;
32
+ onChange: (value: string) => void;
33
+ value: string;
34
+ }
35
+ /**
36
+ * Date field that opens a calendar in a dropdown. `value`, `min` and `max` are ISO dates (`YYYY-MM-DD`); the trigger shows `value` formatted for `locale`.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * <DatePicker
41
+ * id="due-date"
42
+ * locale="en-GB"
43
+ * nextLabel="Next month"
44
+ * onChange={setDueDate}
45
+ * previousLabel="Previous month"
46
+ * value={dueDate}
47
+ * />
48
+ * ```
49
+ */
50
+ export declare function DatePicker({ id, min, max, onChange, value, disabled, locale, previousLabel, nextLabel, }: DatePickerProps): import("react").JSX.Element;
51
+ export {};
@@ -0,0 +1,65 @@
1
+ import { type ReactNode } from 'react';
2
+ export type ControlSize = 'xs' | 'sm' | 'md' | 'lg';
3
+ export interface FieldProps {
4
+ label: string;
5
+ hint?: string;
6
+ error?: string;
7
+ /** Id of the single control inside `children`; the legend label points at it. Omit for a group of controls. */
8
+ controlId?: string;
9
+ /** Base id for the message paragraphs when there is no `controlId`, so controls can reference them. */
10
+ id?: string;
11
+ children: ReactNode;
12
+ className?: string;
13
+ }
14
+ /** Ids of the hint and error paragraphs, derived from the control id. */
15
+ export declare const fieldIds: (controlId: string) => {
16
+ hint: string;
17
+ error: string;
18
+ };
19
+ /**
20
+ * `aria-describedby` value for a control: the caller's ids first, then only the messages that are rendered.
21
+ * Returns undefined when there is nothing to list.
22
+ */
23
+ export declare function fieldDescribedBy(controlId: string, hint?: string, error?: string, callerIds?: string): string | undefined;
24
+ /**
25
+ * Hint (muted) or error (alert) text under a field or a checkbox. daisyUI's `label` never wraps, so long text needs `whitespace-normal`.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * <FieldMessage id="email-error" tone="error">
30
+ * Enter a valid email address.
31
+ * </FieldMessage>
32
+ * ```
33
+ */
34
+ export declare function FieldMessage({ children, id, tone, }: {
35
+ children: ReactNode;
36
+ id?: string;
37
+ tone?: 'hint' | 'error';
38
+ }): import("react").JSX.Element;
39
+ /**
40
+ * The hint and error paragraphs of a control, with the ids `fieldDescribedBy` references.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * <FieldMessages controlId="email" error={errors.email} hint="We never share it." />
45
+ * ```
46
+ */
47
+ export declare function FieldMessages({ controlId, hint, error, }: {
48
+ controlId: string;
49
+ hint?: string;
50
+ error?: string;
51
+ }): import("react").JSX.Element;
52
+ /**
53
+ * Shared labelled form group: a fieldset whose legend names the control,
54
+ * with an optional muted hint and an optional error message.
55
+ * Without `controlId` it labels a group of controls (radios, checkboxes) instead.
56
+ * `id` sets the base id of the message paragraphs when a group needs to reference them.
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * <Field controlId="iban" hint="26 digits, no spaces." label="Account number">
61
+ * <input className="input" id="iban" inputMode="numeric" />
62
+ * </Field>
63
+ * ```
64
+ */
65
+ export declare function Field({ label, hint, error, controlId, id, children, className }: FieldProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import { type ControlSize } from './Field';
3
+ export interface FileInputProps extends Omit<ComponentPropsWithRef<'input'>, 'size' | 'type'> {
4
+ label?: string;
5
+ hint?: string;
6
+ error?: string;
7
+ controlSize?: ControlSize;
8
+ /** Stretches to the container width. Defaults to true. */
9
+ fullWidth?: boolean;
10
+ }
11
+ /**
12
+ * Shared file picker. Pass `label` to get a labelled Field; omit it for the bare control.
13
+ * Hint and error render below the control either way.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <FileInput accept="image/*" label="Avatar" />
18
+ * ```
19
+ */
20
+ export declare function FileInput({ label, hint, error, controlSize, fullWidth, className, id, 'aria-describedby': callerDescribedBy, ...props }: FileInputProps): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ export type FilterBarProps = ComponentPropsWithoutRef<'div'> & {
3
+ children: ReactNode;
4
+ actions?: ReactNode;
5
+ className?: string;
6
+ };
7
+ /**
8
+ * Row of compact filter controls that wraps on narrow screens. `actions` sit at its end.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <FilterBar actions={<Button tone="ghost">Clear</Button>}>
13
+ * <Input aria-label="Search" placeholder="Search" />
14
+ * <Select aria-label="Status">
15
+ * <option>All</option>
16
+ * <option>Paid</option>
17
+ * </Select>
18
+ * </FilterBar>
19
+ * ```
20
+ */
21
+ export declare function FilterBar({ children, actions, className, ...rest }: FilterBarProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ export interface FilterRowProps extends ComponentPropsWithoutRef<'div'> {
3
+ children: ReactNode;
4
+ onRemove?: () => void;
5
+ removeLabel?: string;
6
+ }
7
+ /**
8
+ * One filter condition on a single row that scrolls sideways, with a remove button when `onRemove` is set.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <FilterRow onRemove={() => removeFilter(index)} removeLabel="Remove filter">
13
+ * <Select aria-label="Field">
14
+ * <option>Amount</option>
15
+ * </Select>
16
+ * <Input aria-label="Value" type="number" />
17
+ * </FilterRow>
18
+ * ```
19
+ */
20
+ export declare function FilterRow({ children, className, onRemove, removeLabel, ...rest }: FilterRowProps): import("react").JSX.Element;
@@ -0,0 +1,28 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface FormActionsProps {
3
+ /** Shown above the buttons as an assertive error alert. */
4
+ error?: ReactNode;
5
+ /** Disables both buttons and switches the save label to `savingLabel`. */
6
+ saving?: boolean;
7
+ saveLabel: ReactNode;
8
+ savingLabel?: ReactNode;
9
+ cancelLabel: ReactNode;
10
+ onCancel: () => void;
11
+ className?: string;
12
+ }
13
+ /**
14
+ * Error alert plus submit and cancel buttons for the end of a form.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <FormActions
19
+ * cancelLabel="Cancel"
20
+ * error={saveError}
21
+ * onCancel={close}
22
+ * saveLabel="Save"
23
+ * saving={isSaving}
24
+ * savingLabel="Saving"
25
+ * />
26
+ * ```
27
+ */
28
+ export declare const FormActions: ({ cancelLabel, className, error, onCancel, saveLabel, saving, savingLabel, }: FormActionsProps) => import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { type ChangeEventHandler, type FocusEventHandler, type Ref } from 'react';
2
+ /**
3
+ * Props an uncontrolled input needs from a form library. Matches the result of react-hook-form's
4
+ * `register()` (checked in `FormField.spec.tsx`), without depending on that package.
5
+ */
6
+ export interface FieldRegistration {
7
+ name: string;
8
+ onChange: ChangeEventHandler<HTMLInputElement>;
9
+ onBlur: FocusEventHandler<HTMLInputElement>;
10
+ ref: Ref<HTMLInputElement>;
11
+ disabled?: boolean;
12
+ max?: number | string;
13
+ maxLength?: number;
14
+ min?: number | string;
15
+ minLength?: number;
16
+ pattern?: string;
17
+ required?: boolean;
18
+ }
19
+ export interface FormFieldProps {
20
+ label: string;
21
+ type: 'email' | 'password' | 'text';
22
+ registration: FieldRegistration;
23
+ errorMessage?: string;
24
+ hint?: string;
25
+ }
26
+ /**
27
+ * Shared labeled auth form field with optional hint and validation message.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * <FormField
32
+ * errorMessage={errors.email?.message}
33
+ * label="Email"
34
+ * registration={register('email')}
35
+ * type="email"
36
+ * />
37
+ * ```
38
+ */
39
+ export declare function FormField({ label, type, registration, errorMessage, hint }: FormFieldProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import { type ControlSize } from './Field';
3
+ export interface InputProps extends Omit<ComponentPropsWithRef<'input'>, 'size'> {
4
+ label?: string;
5
+ hint?: string;
6
+ error?: string;
7
+ controlSize?: ControlSize;
8
+ /** Stretches to the container width. Defaults to true. */
9
+ fullWidth?: boolean;
10
+ }
11
+ /**
12
+ * Shared text input. Pass `label` to get a labelled Field; omit it for the bare control
13
+ * (for example in filter bars). Hint and error render below the control either way.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <Input hint="We never share it." label="Email" type="email" />
18
+ * ```
19
+ */
20
+ export declare function Input({ label, hint, error, controlSize, fullWidth, className, id, 'aria-describedby': callerDescribedBy, ...props }: InputProps): import("react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import { type ControlSize } from './Field';
3
+ export interface RadioProps extends Omit<ComponentPropsWithRef<'input'>, 'size' | 'type'> {
4
+ label: string;
5
+ hint?: string;
6
+ error?: string;
7
+ controlSize?: ControlSize;
8
+ }
9
+ export interface RadioOption {
10
+ value: string;
11
+ label: string;
12
+ disabled?: boolean;
13
+ }
14
+ export interface RadioGroupProps {
15
+ legend: string;
16
+ name: string;
17
+ onChange: (value: string) => void;
18
+ options: RadioOption[];
19
+ orientation?: 'vertical' | 'horizontal';
20
+ value: string;
21
+ hint?: string;
22
+ error?: string;
23
+ }
24
+ /**
25
+ * One radio button with its label wrapped around it. Hint and error render below it.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * <Radio label="Monthly" name="billing" value="monthly" />
30
+ * ```
31
+ */
32
+ export declare function Radio({ className, controlSize, error, hint, id, label, 'aria-describedby': callerDescribedBy, ...props }: RadioProps): import("react").JSX.Element;
33
+ /**
34
+ * Radios grouped in a fieldset named by `legend`. Arrow keys move selection natively.
35
+ * Hint and error sit under the group; each radio references them. aria-invalid goes on the
36
+ * radiogroup wrapper because ARIA does not allow it on a radio.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * <RadioGroup
41
+ * legend="Billing"
42
+ * name="billing"
43
+ * onChange={setBilling}
44
+ * options={[
45
+ * { value: 'monthly', label: 'Monthly' },
46
+ * { value: 'yearly', label: 'Yearly' },
47
+ * ]}
48
+ * value={billing}
49
+ * />
50
+ * ```
51
+ */
52
+ export declare function RadioGroup({ error, hint, legend, name, onChange, options, orientation, value, }: RadioGroupProps): import("react").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import type { ComponentPropsWithoutRef } from 'react';
2
+ import type { ControlSize } from './Field';
3
+ import type { StatusPurpose } from '../internal/purpose';
4
+ export type RangePurpose = 'primary' | StatusPurpose;
5
+ export interface RangeProps extends Pick<ComponentPropsWithoutRef<'input'>, 'disabled' | 'onPointerCancel' | 'onPointerDown' | 'onPointerUp'> {
6
+ /** Accessible name. Required because a range has no visible label here. */
7
+ label: string;
8
+ max: number;
9
+ min: number;
10
+ onChange: (value: number) => void;
11
+ purpose?: RangePurpose;
12
+ size?: ControlSize;
13
+ step?: number;
14
+ value: number;
15
+ }
16
+ /**
17
+ * Shared slider. Keyboard arrows and Home/End come from the native input. Pointer props reach the input for drag handling.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <Range label="Volume" max={100} min={0} onChange={setVolume} value={volume} />
22
+ * ```
23
+ */
24
+ export declare const Range: ({ label, max, min, onChange, purpose, size, step, value, ...pointer }: RangeProps) => import("react").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { type ButtonSize } from '../actions/Button';
2
+ export interface SegmentedOption {
3
+ value: string;
4
+ label: string;
5
+ disabled?: boolean;
6
+ }
7
+ export interface SegmentedControlProps {
8
+ /** Accessible name of the group. */
9
+ label: string;
10
+ /** Stretch to the container width and share it equally between options. */
11
+ fullWidth?: boolean;
12
+ onChange: (value: string) => void;
13
+ options: SegmentedOption[];
14
+ size?: ButtonSize;
15
+ value: string;
16
+ }
17
+ /**
18
+ * Single-selection toggle group: a bordered track with the selected option as a bordered sheet-coloured pill.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <SegmentedControl
23
+ * label="View"
24
+ * onChange={setView}
25
+ * options={[
26
+ * { value: 'list', label: 'List' },
27
+ * { value: 'grid', label: 'Grid' },
28
+ * ]}
29
+ * value={view}
30
+ * />
31
+ * ```
32
+ */
33
+ export declare const SegmentedControl: ({ fullWidth, label, onChange, options, size, value, }: SegmentedControlProps) => import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import { type ControlSize } from './Field';
3
+ export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, 'size'> {
4
+ label?: string;
5
+ hint?: string;
6
+ error?: string;
7
+ controlSize?: ControlSize;
8
+ /** Stretches to the container width. Defaults to true. */
9
+ fullWidth?: boolean;
10
+ }
11
+ /**
12
+ * Shared select. Pass `label` to get a labelled Field; omit it for the bare control.
13
+ * Hint and error render below the control either way. Pass `<option>` elements as children.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <Select defaultValue="PLN" label="Currency">
18
+ * <option value="PLN">PLN</option>
19
+ * <option value="EUR">EUR</option>
20
+ * </Select>
21
+ * ```
22
+ */
23
+ export declare function Select({ label, hint, error, controlSize, fullWidth, className, id, 'aria-describedby': callerDescribedBy, ...props }: SelectProps): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ export interface SwitchProps extends Omit<ComponentPropsWithRef<'input'>, 'size' | 'type'> {
3
+ label: string;
4
+ hint?: string;
5
+ error?: string;
6
+ }
7
+ /**
8
+ * Shared switch with its label wrapped around it. Hint and error render below it.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <Switch defaultChecked label="Email notifications" />
13
+ * ```
14
+ */
15
+ export declare function Switch({ label, hint, error, className, id, 'aria-describedby': callerDescribedBy, ...props }: SwitchProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import { type ControlSize } from './Field';
3
+ export interface TextareaProps extends ComponentPropsWithRef<'textarea'> {
4
+ label?: string;
5
+ hint?: string;
6
+ error?: string;
7
+ controlSize?: ControlSize;
8
+ /** Stretches to the container width. Defaults to true. */
9
+ fullWidth?: boolean;
10
+ }
11
+ /**
12
+ * Shared multi-line text field. Pass `label` to get a labelled Field; omit it for the bare control.
13
+ * Hint and error render below the control either way.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <Textarea label="Notes" rows={4} />
18
+ * ```
19
+ */
20
+ export declare function Textarea({ label, hint, error, controlSize, fullWidth, className, id, 'aria-describedby': callerDescribedBy, ...props }: TextareaProps): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ interface TimePickerProps {
2
+ id: string;
3
+ value: string;
4
+ max?: string;
5
+ disabled?: boolean;
6
+ label: string;
7
+ selectHourLabel: string;
8
+ selectMinuteLabel: string;
9
+ changeHourLabel: string;
10
+ onChange: (value: string) => void;
11
+ }
12
+ /**
13
+ * Time field that opens an hour grid, then a minute grid, in a dropdown. `value` and `max` use `HH:MM`; `max` defaults to `23:59`.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <TimePicker
18
+ * changeHourLabel="Change hour"
19
+ * id="start-time"
20
+ * label="Start time"
21
+ * onChange={setStartTime}
22
+ * selectHourLabel="Hour"
23
+ * selectMinuteLabel="Minute"
24
+ * value={startTime}
25
+ * />
26
+ * ```
27
+ */
28
+ export declare function TimePicker({ id, value, max, disabled, label, selectHourLabel, selectMinuteLabel, changeHourLabel, onChange, }: TimePickerProps): import("react").JSX.Element;
29
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Labelled form controls, date and time pickers, filter bars and form actions.
3
+ *
4
+ * @module @ksojecki/purpose-ui/forms
5
+ */
6
+ export * from './Field';
7
+ export * from './FormField';
8
+ export * from './Input';
9
+ export * from './Select';
10
+ export * from './Textarea';
11
+ export * from './Checkbox';
12
+ export * from './Radio';
13
+ export * from './Range';
14
+ export * from './FileInput';
15
+ export * from './Switch';
16
+ export * from './SegmentedControl';
17
+ export * from './FilterBar';
18
+ export * from './FilterRow';
19
+ export * from './FormActions';
20
+ export { DatePicker } from './DatePicker';
21
+ export * from './TimePicker';