@speles7172/controls 0.7.0 → 0.7.2

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.
@@ -0,0 +1,47 @@
1
+ import type { ButtonHTMLAttributes, ComponentType } from 'react';
2
+ /**
3
+ * What an icon button's colour means once somebody reaches for it.
4
+ *
5
+ * Named for meaning, like a badge's tone: `danger` is a delete, `ok` an
6
+ * approve, `accent` the ordinary "act on this". At rest every tone is the same
7
+ * muted grey — six actions in a row are six quiet glyphs rather than a traffic
8
+ * light — and the colour arrives on hover and focus, as the answer to "what will
9
+ * this do".
10
+ */
11
+ export type IconButtonTone = 'neutral' | 'accent' | 'danger' | 'ok';
12
+ /** 28px for a row action in a dense table, 32px everywhere else. */
13
+ export type IconButtonSize = 'sm' | 'md';
14
+ /** The shape an icon in the controls' set has; any lucide icon fits. */
15
+ export type IconComponent = ComponentType<{
16
+ size?: number | string;
17
+ 'aria-hidden'?: boolean | 'true' | 'false';
18
+ }>;
19
+ export interface IconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'title' | 'aria-label'> {
20
+ /** The glyph — a component from the controls' icon set, e.g. `EditIcon`. */
21
+ icon: IconComponent;
22
+ /**
23
+ * What pressing it does, in the reader's language. Required, and both the
24
+ * accessible name and the tooltip: an icon-only button carries no text, so
25
+ * this string is the whole of what names it — to a screen reader and, through
26
+ * `title`, to anyone hovering it. Name the record where a column of them
27
+ * repeats: `Delete Camps`, not `Delete`.
28
+ */
29
+ label: string;
30
+ tone?: IconButtonTone;
31
+ size?: IconButtonSize;
32
+ }
33
+ /**
34
+ * An icon-only button: the verb a table row repeats, or an action in a dialog's
35
+ * header.
36
+ *
37
+ * The label is not optional, because an unnamed icon button is invisible to a
38
+ * screen reader and a mystery on a touch screen; making it a required prop is
39
+ * what stops one being written. It is rendered as both `aria-label` and
40
+ * `title` from the one string, so the two can never drift apart.
41
+ *
42
+ * Carries no `.ctl` of its own — like `<Badge>`, it is an inline part that takes
43
+ * its tokens from the `.ctl` around it. Putting the class here would redeclare
44
+ * the light palette on every button and override a dark host.
45
+ */
46
+ export declare function IconButton({ icon: Icon, label, tone, size, type, className, ...rest }: IconButtonProps): import("react").JSX.Element;
47
+ //# sourceMappingURL=IconButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../src/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEjE;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;AAEpE,oEAAoE;AACpE,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,CAAC;AAElH,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,YAAY,CAAC;IAC1F,4EAA4E;IAC5E,IAAI,EAAE,aAAa,CAAC;IACpB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAI,EAAE,IAAI,EACV,KAAK,EACL,IAAgB,EAChB,IAAW,EACX,IAAe,EACf,SAAS,EACT,GAAG,IAAI,EACR,EAAE,eAAe,+BAYjB"}
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * An icon-only button: the verb a table row repeats, or an action in a dialog's
4
+ * header.
5
+ *
6
+ * The label is not optional, because an unnamed icon button is invisible to a
7
+ * screen reader and a mystery on a touch screen; making it a required prop is
8
+ * what stops one being written. It is rendered as both `aria-label` and
9
+ * `title` from the one string, so the two can never drift apart.
10
+ *
11
+ * Carries no `.ctl` of its own — like `<Badge>`, it is an inline part that takes
12
+ * its tokens from the `.ctl` around it. Putting the class here would redeclare
13
+ * the light palette on every button and override a dark host.
14
+ */
15
+ export function IconButton({ icon: Icon, label, tone = 'neutral', size = 'md', type = 'button', className, ...rest }) {
16
+ return (_jsx("button", { ...rest, type: type, "aria-label": label, title: label, className: `ctl-icon-btn ctl-icon-btn-${size} ctl-icon-btn-${tone}${className === undefined ? '' : ` ${className}`}`, children: _jsx(Icon, { size: size === 'sm' ? 15 : 16, "aria-hidden": "true" }) }));
17
+ }
18
+ //# sourceMappingURL=IconButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../src/IconButton.tsx"],"names":[],"mappings":";AAmCA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,IAAI,EAAE,IAAI,EACV,KAAK,EACL,IAAI,GAAG,SAAS,EAChB,IAAI,GAAG,IAAI,EACX,IAAI,GAAG,QAAQ,EACf,SAAS,EACT,GAAG,IAAI,EACS;IAChB,OAAO,CACL,oBACM,IAAI,EACR,IAAI,EAAE,IAAI,gBACE,KAAK,EACjB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,6BAA6B,IAAI,iBAAiB,IAAI,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,EAAE,YAEpH,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAc,MAAM,GAAG,GACnD,CACV,CAAC;AACJ,CAAC"}
package/dist/Modal.d.ts CHANGED
@@ -22,6 +22,13 @@ export interface ModalProps {
22
22
  children: ReactNode;
23
23
  /** A row of actions pinned below the scrolling body. */
24
24
  footer?: ReactNode;
25
+ /**
26
+ * Actions drawn in the header, before the close button — an edit pencil, a
27
+ * history icon. Usually `<IconButton>`s; anything rendered here can leave the
28
+ * current form through {@link useModalGuard} and get the same unsaved-changes
29
+ * prompt the close button does.
30
+ */
31
+ headerActions?: ReactNode;
25
32
  /** Widen the panel for content that is mostly table, picture or stack trace. */
26
33
  wide?: boolean;
27
34
  /**
@@ -78,6 +85,21 @@ export interface ModalProps {
78
85
  className?: string;
79
86
  theme?: ControlTheme;
80
87
  }
88
+ /**
89
+ * Leave whatever the dialog is showing, asking first when a form in it holds
90
+ * unsaved edits — the same *Save / Discard / Keep editing* prompt the close
91
+ * button raises, but running `action` instead of closing.
92
+ */
93
+ export type ModalGuard = (action: () => void) => void;
94
+ /**
95
+ * The guard of the `<Modal>` around this component.
96
+ *
97
+ * For a control inside a dialog that moves away from a form without closing —
98
+ * a record's "back to the read view" — and must not drop somebody's typing
99
+ * silently on the way. `guard(() => setMode('view'))` switches at once when
100
+ * nothing was edited, and asks when something was.
101
+ */
102
+ export declare function useModalGuard(): ModalGuard;
81
103
  /**
82
104
  * The modal shell.
83
105
  *
@@ -111,5 +133,5 @@ export interface ModalProps {
111
133
  * so a dark console would open a light dialog. `position: fixed` covers the
112
134
  * viewport from wherever the element sits.
113
135
  */
114
- export declare function Modal({ title, onClose, children, footer, wide, closeLabel, dismissible, dirty, onSave, unsavedLabels, labelledBy, className, theme, }: ModalProps): import("react").JSX.Element;
136
+ export declare function Modal({ title, onClose, children, footer, headerActions, wide, closeLabel, dismissible, dirty, onSave, unsavedLabels, labelledBy, className, theme, }: ModalProps): import("react").JSX.Element;
115
137
  //# sourceMappingURL=Modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,E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F;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAuBD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAKtD;;;;;;;GAOG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AA0DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,aAAa,EACb,IAAY,EACZ,UAAoB,EACpB,WAAkB,EAClB,KAAK,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,SAAS,EACT,KAAe,GAChB,EAAE,UAAU,+BAiUZ"}
package/dist/Modal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useId, useRef, useState } from 'react';
2
+ import { createContext, useContext, useEffect, useId, useRef, useState } from 'react';
3
3
  import { CheckIcon, CloseIcon, DeleteIcon } from './icons.js';
4
4
  const UNSAVED_LABELS = {
5
5
  title: 'Unsaved changes',
@@ -29,6 +29,19 @@ const UNSAVED_LABELS = {
29
29
  * right entry.
30
30
  */
31
31
  const openModals = [];
32
+ /** Outside a `<Modal>` there is nothing to guard, and the action runs at once. */
33
+ const ModalGuardContext = createContext((action) => action());
34
+ /**
35
+ * The guard of the `<Modal>` around this component.
36
+ *
37
+ * For a control inside a dialog that moves away from a form without closing —
38
+ * a record's "back to the read view" — and must not drop somebody's typing
39
+ * silently on the way. `guard(() => setMode('view'))` switches at once when
40
+ * nothing was edited, and asks when something was.
41
+ */
42
+ export function useModalGuard() {
43
+ return useContext(ModalGuardContext);
44
+ }
32
45
  /** What `body.style.overflow` was before the first modal took it. */
33
46
  let releasedOverflow = '';
34
47
  /** Everything a `Tab` can land on, in document order. */
@@ -108,7 +121,7 @@ function submitterOf(form) {
108
121
  * so a dark console would open a light dialog. `position: fixed` covers the
109
122
  * viewport from wherever the element sits.
110
123
  */
111
- export function Modal({ title, onClose, children, footer, wide = false, closeLabel = 'Close', dismissible = true, dirty, onSave, unsavedLabels, labelledBy, className, theme = 'light', }) {
124
+ export function Modal({ title, onClose, children, footer, headerActions, wide = false, closeLabel = 'Close', dismissible = true, dirty, onSave, unsavedLabels, labelledBy, className, theme = 'light', }) {
112
125
  const panel = useRef(null);
113
126
  const confirmPanel = useRef(null);
114
127
  const titleId = useId();
@@ -124,6 +137,20 @@ export function Modal({ title, onClose, children, footer, wide = false, closeLab
124
137
  const [confirming, setConfirming] = useState(false);
125
138
  /** The form *Save* submitted, whose leaving means the save went through. */
126
139
  const savedForm = useRef(null);
140
+ /**
141
+ * What finishes once the prompt is answered with Discard, or once a Save has
142
+ * gone through: `null` for closing the dialog, else the action a
143
+ * {@link useModalGuard} caller asked for.
144
+ */
145
+ const pendingAction = useRef(null);
146
+ const finish = () => {
147
+ const action = pendingAction.current;
148
+ pendingAction.current = null;
149
+ if (action === null)
150
+ onClose();
151
+ else
152
+ action();
153
+ };
127
154
  const onReach = (event) => {
128
155
  const form = event.target instanceof Element ? event.target.closest('form') : null;
129
156
  if (form === null || !panel.current?.contains(form))
@@ -144,26 +171,47 @@ export function Modal({ title, onClose, children, footer, wide = false, closeLab
144
171
  const requestClose = () => {
145
172
  if (!dismissible)
146
173
  return;
174
+ pendingAction.current = null;
147
175
  const unsaved = dirty ?? editedForm() !== null;
148
176
  if (unsaved)
149
177
  setConfirming(true);
150
178
  else
151
179
  onClose();
152
180
  };
181
+ /** The same question, for leaving a form without closing — see {@link useModalGuard}. */
182
+ const guard = (action) => {
183
+ // A locked dialog (a save under way) stays where it is, as its close does.
184
+ if (!dismissible)
185
+ return;
186
+ const unsaved = dirty ?? editedForm() !== null;
187
+ if (!unsaved) {
188
+ action();
189
+ return;
190
+ }
191
+ pendingAction.current = action;
192
+ setConfirming(true);
193
+ };
153
194
  const discard = () => {
154
195
  setConfirming(false);
155
- onClose();
196
+ // An earlier Save that was refused is over: its form leaving now is the discard, not that save.
197
+ savedForm.current = null;
198
+ finish();
156
199
  };
157
200
  const save = () => {
158
201
  setConfirming(false);
159
202
  if (onSave !== undefined) {
203
+ // The caller's save decides what happens next; a guarded action does not
204
+ // outlive it.
205
+ pendingAction.current = null;
160
206
  onSave();
161
207
  return;
162
208
  }
163
209
  const form = editedForm();
164
210
  const submitter = form === null ? null : submitterOf(form);
165
- if (form === null || submitter === null)
211
+ if (form === null || submitter === null) {
212
+ pendingAction.current = null;
166
213
  return;
214
+ }
167
215
  savedForm.current = form;
168
216
  form.requestSubmit(submitter);
169
217
  };
@@ -175,7 +223,7 @@ export function Modal({ title, onClose, children, footer, wide = false, closeLab
175
223
  useEffect(() => {
176
224
  if (savedForm.current !== null && !savedForm.current.isConnected) {
177
225
  savedForm.current = null;
178
- onClose();
226
+ finish();
179
227
  }
180
228
  });
181
229
  // Into the prompt when it opens, and back to the panel when it is waved away
@@ -226,8 +274,10 @@ export function Modal({ title, onClose, children, footer, wide = false, closeLab
226
274
  // the key that this dialog refused.
227
275
  event.stopPropagation();
228
276
  // Escape on the prompt is "keep editing" — the gentlest way out of it.
229
- if (confirming)
277
+ if (confirming) {
278
+ pendingAction.current = null;
230
279
  setConfirming(false);
280
+ }
231
281
  else
232
282
  requestClose();
233
283
  return;
@@ -298,13 +348,16 @@ export function Modal({ title, onClose, children, footer, wide = false, closeLab
298
348
  // this may be about to open, or out of the dialog left standing.
299
349
  event.preventDefault();
300
350
  requestClose();
301
- }, children: _jsxs("div", { className: `ctl-modal${wide ? ' ctl-modal-wide' : ''}${className ? ` ${className}` : ''}`, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy ?? titleId, tabIndex: -1, ref: panel, onFocusCapture: onReach, onPointerDownCapture: onReach, onMouseDownCapture: onReach, children: [_jsxs("div", { className: "ctl-modal-head", children: [_jsx("h2", { className: "ctl-modal-title", id: titleId, children: title }), _jsx("button", { type: "button", className: "ctl-modal-close", "aria-label": closeLabel,
351
+ }, children: _jsxs("div", { className: `ctl-modal${wide ? ' ctl-modal-wide' : ''}${className ? ` ${className}` : ''}`, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy ?? titleId, tabIndex: -1, ref: panel, onFocusCapture: onReach, onPointerDownCapture: onReach, onMouseDownCapture: onReach, children: [_jsxs("div", { className: "ctl-modal-head", children: [_jsx("h2", { className: "ctl-modal-title", id: titleId, children: title }), headerActions !== undefined && (_jsx("div", { className: "ctl-modal-head-actions", children: _jsx(ModalGuardContext.Provider, { value: guard, children: headerActions }) })), _jsx("button", { type: "button", className: "ctl-modal-close", "aria-label": closeLabel,
302
352
  // The same string on `title`: on a touch screen there is no hover,
303
353
  // and on a desktop the tooltip is the only thing that names an
304
354
  // icon-only control to somebody not using a screen reader.
305
- title: closeLabel, disabled: !dismissible, onClick: requestClose, children: _jsx(CloseIcon, { size: 18, "aria-hidden": "true" }) })] }), _jsx("div", { className: "ctl-modal-body", children: children }), footer !== undefined && _jsx("div", { className: "ctl-modal-foot", children: footer }), confirming && (
355
+ title: closeLabel, disabled: !dismissible, onClick: requestClose, children: _jsx(CloseIcon, { size: 18, "aria-hidden": "true" }) })] }), _jsxs(ModalGuardContext.Provider, { value: guard, children: [_jsx("div", { className: "ctl-modal-body", children: children }), footer !== undefined && _jsx("div", { className: "ctl-modal-foot", children: footer })] }), confirming && (
306
356
  // Inside the panel rather than a second modal: it asks about *this*
307
357
  // dialog, covers it, and needs none of the stack bookkeeping above.
308
- _jsx("div", { className: "ctl-modal-confirm-scrim", children: _jsxs("div", { className: "ctl-modal-confirm", role: "alertdialog", "aria-modal": "true", "aria-labelledby": `${confirmId}-title`, "aria-describedby": `${confirmId}-message`, tabIndex: -1, ref: confirmPanel, children: [_jsx("h3", { className: "ctl-modal-confirm-title", id: `${confirmId}-title`, children: words.title }), _jsx("p", { className: "ctl-modal-confirm-message", id: `${confirmId}-message`, children: canSave ? words.message : words.discardMessage }), _jsxs("div", { className: "ctl-modal-confirm-actions", children: [_jsx("button", { type: "button", className: "ctl-btn ctl-btn-ghost", onClick: () => setConfirming(false), children: words.keepEditing }), _jsxs("button", { type: "button", className: "ctl-btn ctl-btn-danger", onClick: discard, children: [_jsx(DeleteIcon, { size: 16, "aria-hidden": "true" }), words.discard] }), canSave && (_jsxs("button", { type: "button", className: "ctl-btn ctl-btn-primary", onClick: save, children: [_jsx(CheckIcon, { size: 16, "aria-hidden": "true" }), words.save] }))] })] }) }))] }) }));
358
+ _jsx("div", { className: "ctl-modal-confirm-scrim", children: _jsxs("div", { className: "ctl-modal-confirm", role: "alertdialog", "aria-modal": "true", "aria-labelledby": `${confirmId}-title`, "aria-describedby": `${confirmId}-message`, tabIndex: -1, ref: confirmPanel, children: [_jsx("h3", { className: "ctl-modal-confirm-title", id: `${confirmId}-title`, children: words.title }), _jsx("p", { className: "ctl-modal-confirm-message", id: `${confirmId}-message`, children: canSave ? words.message : words.discardMessage }), _jsxs("div", { className: "ctl-modal-confirm-actions", children: [_jsx("button", { type: "button", className: "ctl-btn ctl-btn-ghost", onClick: () => {
359
+ pendingAction.current = null;
360
+ setConfirming(false);
361
+ }, children: words.keepEditing }), _jsxs("button", { type: "button", className: "ctl-btn ctl-btn-danger", onClick: discard, children: [_jsx(DeleteIcon, { size: 16, "aria-hidden": "true" }), words.discard] }), canSave && (_jsxs("button", { type: "button", className: "ctl-btn ctl-btn-primary", onClick: save, children: [_jsx(CheckIcon, { size: 16, "aria-hidden": "true" }), words.save] }))] })] }) }))] }) }));
309
362
  }
310
363
  //# sourceMappingURL=Modal.js.map
package/dist/Modal.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC3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AO,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,GAC7C,EACJ,eAAK,SAAS,EAAC,2BAA2B,aACxC,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,uBAAuB,EACjC,OAAO,EAAE,GAAG,EAAE;4CACZ,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;4CAC7B,aAAa,CAAC,KAAK,CAAC,CAAC;wCACvB,CAAC,YAEA,KAAK,CAAC,WAAW,GACX,EACT,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,wBAAwB,EAAC,OAAO,EAAE,OAAO,aACvE,KAAC,UAAU,IAAC,IAAI,EAAE,EAAE,iBAAc,MAAM,GAAG,EAC1C,KAAK,CAAC,OAAO,IACP,EACR,OAAO,IAAI,CACV,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,yBAAyB,EAAC,OAAO,EAAE,IAAI,aACrE,KAAC,SAAS,IAAC,IAAI,EAAE,EAAE,iBAAc,MAAM,GAAG,EACzC,KAAK,CAAC,IAAI,IACJ,CACV,IACG,IACF,GACF,CACP,IACG,GACF,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type ModalProps } from './Modal.js';
3
+ /** Whether the record is being read or changed. */
4
+ export type RecordModalMode = 'view' | 'edit';
5
+ /** The words a record dialog adds to a `<Modal>`, for an application that does not read English. */
6
+ export interface RecordModalLabels {
7
+ /** The pencil in the header, read mode. Default `Edit`. */
8
+ edit?: string;
9
+ /** The close button. Default `Close`. */
10
+ close?: string;
11
+ /** The eye in the header, edit mode — back to the read view. Default `Back to details`. */
12
+ view?: string;
13
+ }
14
+ /** What the edit content is handed, for a form that ends by going back to the read view. */
15
+ export interface RecordModalEditControls {
16
+ /** Back to the read view at once — call it after a save, or from the form's Cancel. */
17
+ view(): void;
18
+ }
19
+ export interface RecordModalProps extends Pick<ModalProps, 'dirty' | 'onSave' | 'unsavedLabels' | 'wide' | 'theme' | 'dismissible' | 'className'> {
20
+ title: string;
21
+ onClose(): void;
22
+ /** The record as read — usually a `<DetailList>` and the panels under it. */
23
+ view: ReactNode;
24
+ /**
25
+ * The record as a form. Absent, the dialog is read-only and offers no Edit.
26
+ * A function is handed {@link RecordModalEditControls}, so a form whose
27
+ * mode is not controlled can still go back to the read view after it saves.
28
+ */
29
+ edit?: ReactNode | ((controls: RecordModalEditControls) => ReactNode);
30
+ /** The mode, when the caller holds it. Pass with `onModeChange`. */
31
+ mode?: RecordModalMode;
32
+ /** Told of every switch — controlled or not. */
33
+ onModeChange?(mode: RecordModalMode): void;
34
+ /** Where an uncontrolled dialog starts. Default `view`. */
35
+ initialMode?: RecordModalMode;
36
+ /** More header actions, before Edit — a history icon, a print. Shown in both modes. */
37
+ headerActions?: ReactNode;
38
+ /** The read view's footer: the record's verbs (Approve, Delete). Hidden while editing. */
39
+ footer?: ReactNode;
40
+ /** A footer while editing, for a form whose buttons are not inside it. Usually left out. */
41
+ editFooter?: ReactNode;
42
+ labels?: RecordModalLabels;
43
+ }
44
+ /**
45
+ * A record opened read-first in a dialog, with an Edit pencil in the header that
46
+ * turns the same dialog into its form.
47
+ *
48
+ * Reading comes first because most opens are to look, and a form opened to look
49
+ * at is a form one stray keystroke away from a change nobody meant. The record's
50
+ * verbs sit in the footer of the read view; the form brings its own Save and
51
+ * Cancel.
52
+ *
53
+ * Everything a `<Modal>` does it still does — Escape, the focus trap, and the
54
+ * unsaved-changes prompt on every way out — plus one more way out guarded the
55
+ * same way: going back from the form to the read view.
56
+ */
57
+ export declare function RecordModal({ title, onClose, view, edit, mode: controlledMode, onModeChange, initialMode, headerActions, footer, editFooter, labels, ...modal }: RecordModalProps): import("react").JSX.Element;
58
+ //# sourceMappingURL=RecordModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecordModal.d.ts","sourceRoot":"","sources":["../src/RecordModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,M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ACL,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EAAE,cAAc,EACpB,YAAY,EACZ,WAAoB,EACpB,aAAa,EACb,MAAM,EACN,UAAU,EACV,MAAM,EACN,GAAG,KAAK,EACT,EAAE,gBAAgB,+BA2ClB"}
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { IconButton } from './IconButton.js';
4
+ import { EditIcon, ViewIcon } from './icons.js';
5
+ import { Modal, useModalGuard } from './Modal.js';
6
+ const LABELS = {
7
+ edit: 'Edit',
8
+ close: 'Close',
9
+ view: 'Back to details',
10
+ };
11
+ /**
12
+ * Back to the read view, through the dialog's guard: a form with unsaved edits
13
+ * gets the same *Save / Discard / Keep editing* prompt the close button raises,
14
+ * rather than having its typing thrown away by a header icon.
15
+ */
16
+ function BackToView({ label, onView, disabled }) {
17
+ const guard = useModalGuard();
18
+ return _jsx(IconButton, { icon: ViewIcon, label: label, onClick: () => guard(onView), disabled: disabled });
19
+ }
20
+ /**
21
+ * A record opened read-first in a dialog, with an Edit pencil in the header that
22
+ * turns the same dialog into its form.
23
+ *
24
+ * Reading comes first because most opens are to look, and a form opened to look
25
+ * at is a form one stray keystroke away from a change nobody meant. The record's
26
+ * verbs sit in the footer of the read view; the form brings its own Save and
27
+ * Cancel.
28
+ *
29
+ * Everything a `<Modal>` does it still does — Escape, the focus trap, and the
30
+ * unsaved-changes prompt on every way out — plus one more way out guarded the
31
+ * same way: going back from the form to the read view.
32
+ */
33
+ export function RecordModal({ title, onClose, view, edit, mode: controlledMode, onModeChange, initialMode = 'view', headerActions, footer, editFooter, labels, ...modal }) {
34
+ const words = { ...LABELS, ...labels };
35
+ const [ownMode, setOwnMode] = useState(initialMode);
36
+ const requested = controlledMode ?? ownMode;
37
+ // No form, no edit mode — whatever was asked for.
38
+ const mode = edit === undefined ? 'view' : requested;
39
+ const setMode = (next) => {
40
+ if (controlledMode === undefined)
41
+ setOwnMode(next);
42
+ onModeChange?.(next);
43
+ };
44
+ const actions = (_jsxs(_Fragment, { children: [headerActions, edit !== undefined && mode === 'view' && (_jsx(IconButton, { icon: EditIcon, label: words.edit, tone: "accent", onClick: () => setMode('edit') })), mode === 'edit' && _jsx(BackToView, { label: words.view, onView: () => setMode('view'), disabled: modal.dismissible === false })] }));
45
+ const content = mode === 'edit' && edit !== undefined
46
+ ? typeof edit === 'function'
47
+ ? edit({ view: () => setMode('view') })
48
+ : edit
49
+ : view;
50
+ const foot = mode === 'edit' ? editFooter : footer;
51
+ return (_jsx(Modal, { ...modal, title: title, onClose: onClose, closeLabel: words.close, headerActions: actions, ...(foot === undefined ? {} : { footer: foot }), children: _jsx("div", { className: `ctl-record ctl-record-${mode}`, children: content }) }));
52
+ }
53
+ //# sourceMappingURL=RecordModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecordModal.js","sourceRoot":"","sources":["../src/RecordModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAenE,MAAM,MAAM,GAAgC;IAC1C,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,iBAAiB;CACxB,CAAC;AAmCF;;;;GAIG;AACH,SAAS,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAwD;IACnG,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,OAAO,KAAC,UAAU,IAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ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CAAC;IAEF,MAAM,OAAO,GACX,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,SAAS;QACnC,CAAC,CAAC,OAAO,IAAI,KAAK,UAAU;YAC1B,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,CAAC,CAAC,IAAI;QACR,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,IAAI,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IAEnD,OAAO,CACL,KAAC,KAAK,OACA,KAAK,EACT,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,KAAK,CAAC,KAAK,EACvB,aAAa,EAAE,OAAO,KAClB,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,YAEhD,cAAK,SAAS,EAAE,yBAAyB,IAAI,EAAE,YAAG,OAAO,GAAO,GAC1D,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import type { ControlTheme } from './types.js';
3
+ /** One destination in the menu. */
4
+ export interface SideNavItem {
5
+ key: string;
6
+ label: string;
7
+ icon: ComponentType<{
8
+ size?: number | string;
9
+ 'aria-hidden'?: boolean | 'true' | 'false';
10
+ }>;
11
+ /** The page on screen. Drawn in the accent and announced with `aria-current="page"`. */
12
+ current?: boolean;
13
+ /** Go there. Called on a plain click; with `href`, a ctrl/⌘/middle click is left to the browser. */
14
+ onSelect(): void;
15
+ /**
16
+ * The address, when there is one: the item becomes a link, so it can be
17
+ * opened in a new tab and copied — which a button never can.
18
+ */
19
+ href?: string;
20
+ /** A count or a dot after the label — unread messages, tasks overdue. */
21
+ badge?: ReactNode;
22
+ }
23
+ /** A group of destinations. Without a `label`, it is the top block and cannot fold. */
24
+ export interface SideNavSection {
25
+ key: string;
26
+ label?: string;
27
+ items: readonly SideNavItem[];
28
+ }
29
+ export interface SideNavProps {
30
+ sections: readonly SideNavSection[];
31
+ /** An icon-only rail: section headings go, and each item's label becomes its tooltip. */
32
+ collapsed?: boolean;
33
+ /** The sections open, when the caller holds them. Pass with `onToggleSection`. */
34
+ openSections?: readonly string[];
35
+ /** Told when a section heading is pressed, controlled or not. */
36
+ onToggleSection?(key: string, open: boolean): void;
37
+ /** Where an uncontrolled menu starts. Default: every section open. */
38
+ defaultOpenSections?: readonly string[];
39
+ /**
40
+ * A `localStorage` key under which an uncontrolled menu remembers which
41
+ * sections were folded. Left out, nothing is remembered.
42
+ */
43
+ storageKey?: string;
44
+ /** Above the items — a logo, the application's name, a collapse button. */
45
+ header?: ReactNode;
46
+ /** Pinned below them — who is signed in, sign out. */
47
+ footer?: ReactNode;
48
+ 'aria-label'?: string;
49
+ className?: string;
50
+ theme?: ControlTheme;
51
+ }
52
+ /**
53
+ * An application's vertical menu.
54
+ *
55
+ * Calm by design: one accent, on the page you are on; a section heading small
56
+ * and muted, folding its items behind a chevron; nothing else coloured. Items
57
+ * a person may not reach are not passed — the menu has no idea of permissions,
58
+ * and deciding them is the server's anyway.
59
+ *
60
+ * Every direction is logical, so the same markup sits on the right with its
61
+ * chevrons mirrored in a right-to-left page — which is where it is mostly used.
62
+ *
63
+ * Folded sections are either the caller's (`openSections` +
64
+ * `onToggleSection`) or the menu's own, remembered under `storageKey` when one
65
+ * is given. On the collapsed rail every item is shown, folded or not, since
66
+ * there is no heading left to unfold them with.
67
+ */
68
+ export declare function SideNav({ sections, collapsed, openSections, onToggleSection, defaultOpenSections, storageKey, header, footer, 'aria-label': ariaLabel, className, theme, }: SideNavProps): import("react").JSX.Element;
69
+ //# sourceMappingURL=SideNav.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SideNav.d.ts","sourceRoot":"","sources":["../src/SideNav.tsx"],"names":[],"mappings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