@salmonui/editors 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -2
  3. package/dist/image-editor/ImageEditor.d.ts +59 -0
  4. package/dist/image-editor/ImageEditor.d.ts.map +1 -0
  5. package/dist/image-editor/ImageEditor.js +493 -0
  6. package/dist/image-editor/ImageEditor.js.map +1 -0
  7. package/dist/image-editor/adjust.d.ts +17 -0
  8. package/dist/image-editor/adjust.d.ts.map +1 -0
  9. package/dist/image-editor/adjust.js +53 -0
  10. package/dist/image-editor/adjust.js.map +1 -0
  11. package/dist/image-editor/annotations.d.ts +40 -0
  12. package/dist/image-editor/annotations.d.ts.map +1 -0
  13. package/dist/image-editor/annotations.js +184 -0
  14. package/dist/image-editor/annotations.js.map +1 -0
  15. package/dist/image-editor/draw.d.ts +25 -0
  16. package/dist/image-editor/draw.d.ts.map +1 -0
  17. package/dist/image-editor/draw.js +248 -0
  18. package/dist/image-editor/draw.js.map +1 -0
  19. package/dist/image-editor/engine.d.ts +116 -0
  20. package/dist/image-editor/engine.d.ts.map +1 -0
  21. package/dist/image-editor/engine.js +367 -0
  22. package/dist/image-editor/engine.js.map +1 -0
  23. package/dist/image-editor/geometry.d.ts +41 -0
  24. package/dist/image-editor/geometry.d.ts.map +1 -0
  25. package/dist/image-editor/geometry.js +62 -0
  26. package/dist/image-editor/geometry.js.map +1 -0
  27. package/dist/image-editor/history.d.ts +24 -0
  28. package/dist/image-editor/history.d.ts.map +1 -0
  29. package/dist/image-editor/history.js +31 -0
  30. package/dist/image-editor/history.js.map +1 -0
  31. package/dist/image-editor/interact.d.ts +73 -0
  32. package/dist/image-editor/interact.d.ts.map +1 -0
  33. package/dist/image-editor/interact.js +686 -0
  34. package/dist/image-editor/interact.js.map +1 -0
  35. package/dist/image-editor/items.d.ts +9 -0
  36. package/dist/image-editor/items.d.ts.map +1 -0
  37. package/dist/image-editor/items.js +179 -0
  38. package/dist/image-editor/items.js.map +1 -0
  39. package/dist/image-editor/ops.d.ts +35 -0
  40. package/dist/image-editor/ops.d.ts.map +1 -0
  41. package/dist/image-editor/ops.js +332 -0
  42. package/dist/image-editor/ops.js.map +1 -0
  43. package/dist/image-editor/panels.d.ts +24 -0
  44. package/dist/image-editor/panels.d.ts.map +1 -0
  45. package/dist/image-editor/panels.js +185 -0
  46. package/dist/image-editor/panels.js.map +1 -0
  47. package/dist/image-editor/pixels.d.ts +10 -0
  48. package/dist/image-editor/pixels.d.ts.map +1 -0
  49. package/dist/image-editor/pixels.js +172 -0
  50. package/dist/image-editor/pixels.js.map +1 -0
  51. package/dist/image-editor/transform.d.ts +33 -0
  52. package/dist/image-editor/transform.d.ts.map +1 -0
  53. package/dist/image-editor/transform.js +142 -0
  54. package/dist/image-editor/transform.js.map +1 -0
  55. package/dist/image-editor/types.d.ts +450 -0
  56. package/dist/image-editor/types.d.ts.map +1 -0
  57. package/dist/image-editor/types.js +6 -0
  58. package/dist/image-editor/types.js.map +1 -0
  59. package/dist/image-editor.css +1228 -0
  60. package/dist/image-editor.d.ts +5 -0
  61. package/dist/image-editor.d.ts.map +1 -0
  62. package/dist/image-editor.js +13 -0
  63. package/dist/image-editor.js.map +1 -0
  64. package/dist/inline-edit/InlineEdit.d.ts +6 -0
  65. package/dist/inline-edit/InlineEdit.d.ts.map +1 -0
  66. package/dist/inline-edit/InlineEdit.js +340 -0
  67. package/dist/inline-edit/InlineEdit.js.map +1 -0
  68. package/dist/inline-edit/types.d.ts +177 -0
  69. package/dist/inline-edit/types.d.ts.map +1 -0
  70. package/dist/inline-edit/types.js +2 -0
  71. package/dist/inline-edit/types.js.map +1 -0
  72. package/dist/inline-edit/validate.d.ts +17 -0
  73. package/dist/inline-edit/validate.d.ts.map +1 -0
  74. package/dist/inline-edit/validate.js +34 -0
  75. package/dist/inline-edit/validate.js.map +1 -0
  76. package/dist/inline-edit.css +621 -0
  77. package/dist/inline-edit.d.ts +3 -0
  78. package/dist/inline-edit.d.ts.map +1 -0
  79. package/dist/inline-edit.js +9 -0
  80. package/dist/inline-edit.js.map +1 -0
  81. package/dist/markdown-editor/MarkdownEditor.d.ts +6 -0
  82. package/dist/markdown-editor/MarkdownEditor.d.ts.map +1 -0
  83. package/dist/markdown-editor/MarkdownEditor.js +423 -0
  84. package/dist/markdown-editor/MarkdownEditor.js.map +1 -0
  85. package/dist/markdown-editor/commands.d.ts +69 -0
  86. package/dist/markdown-editor/commands.d.ts.map +1 -0
  87. package/dist/markdown-editor/commands.js +207 -0
  88. package/dist/markdown-editor/commands.js.map +1 -0
  89. package/dist/markdown-editor/dialog.d.ts +19 -0
  90. package/dist/markdown-editor/dialog.d.ts.map +1 -0
  91. package/dist/markdown-editor/dialog.js +88 -0
  92. package/dist/markdown-editor/dialog.js.map +1 -0
  93. package/dist/markdown-editor/items.d.ts +12 -0
  94. package/dist/markdown-editor/items.d.ts.map +1 -0
  95. package/dist/markdown-editor/items.js +110 -0
  96. package/dist/markdown-editor/items.js.map +1 -0
  97. package/dist/markdown-editor/menu-popup.d.ts +14 -0
  98. package/dist/markdown-editor/menu-popup.d.ts.map +1 -0
  99. package/dist/markdown-editor/menu-popup.js +13 -0
  100. package/dist/markdown-editor/menu-popup.js.map +1 -0
  101. package/dist/markdown-editor/types.d.ts +158 -0
  102. package/dist/markdown-editor/types.d.ts.map +1 -0
  103. package/dist/markdown-editor/types.js +2 -0
  104. package/dist/markdown-editor/types.js.map +1 -0
  105. package/dist/markdown-editor.css +1020 -0
  106. package/dist/markdown-editor.d.ts +6 -0
  107. package/dist/markdown-editor.d.ts.map +1 -0
  108. package/dist/markdown-editor.js +12 -0
  109. package/dist/markdown-editor.js.map +1 -0
  110. package/dist/styles.css +1699 -0
  111. package/package.json +53 -4
@@ -0,0 +1,5 @@
1
+ export { ImageEditor, IMAGE_EDITOR_DEFAULT_CROP_RATIOS } from './image-editor/ImageEditor.js';
2
+ export { IMAGE_EDITOR_DEFAULT_LOCALE_TEXT, IMAGE_EDITOR_DEFAULT_QUICK_TOOLBAR, IMAGE_EDITOR_DEFAULT_TOOLBAR } from './image-editor/items.js';
3
+ export { FILTER_PRESETS as IMAGE_EDITOR_FILTER_PRESETS, IMAGE_EDITOR_FILTERS } from './image-editor/adjust.js';
4
+ export type { ImageEditorActions, ImageEditorAdjustments, ImageEditorAnnotation, ImageEditorAnnotationKind, ImageEditorBeforeEvent, ImageEditorBeforeExportEvent, ImageEditorBoxAnnotation, ImageEditorChangeEvent, ImageEditorCrop, ImageEditorCropRatio, ImageEditorCropShape, ImageEditorCustomItem, ImageEditorEditCompleteEvent, ImageEditorEditState, ImageEditorEvent, ImageEditorExportOptions, ImageEditorFilter, ImageEditorFlip, ImageEditorFrame, ImageEditorFrameType, ImageEditorHistoryState, ImageEditorImageAnnotation, ImageEditorInputSource, ImageEditorLocaleText, ImageEditorOperation, ImageEditorPart, ImageEditorPointsAnnotation, ImageEditorProps, ImageEditorQuickItemId, ImageEditorRedactAnnotation, ImageEditorShapeStyle, ImageEditorSource, ImageEditorTextAnnotation, ImageEditorTool, ImageEditorToolbarItem, ImageEditorToolbarItemClickEvent, ImageEditorToolbarItemId, ImageEditorTransform, } from './image-editor/types.js';
5
+ //# sourceMappingURL=image-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-editor.d.ts","sourceRoot":"","sources":["../src/image-editor.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,gCAAgC,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC7I,OAAO,EAAE,cAAc,IAAI,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC/G,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,gCAAgC,EAChC,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import { expectStylesheet } from '@salmonui/core/internal/dev';
3
+ // `@salmonui/editors/image-editor`: ImageEditor:
4
+ // Canvas 2D crop, rotate, straighten, flip, resize, zoom and pan, finetune,
5
+ // filter presets, frames, annotations, redaction, history and export, with
6
+ // zero dependencies. Styles: `@salmonui/editors/image-editor/styles.css`
7
+ // (self-contained: it carries the Button, Menu and Toolbar rules it composes).
8
+ export { ImageEditor, IMAGE_EDITOR_DEFAULT_CROP_RATIOS } from './image-editor/ImageEditor.js';
9
+ export { IMAGE_EDITOR_DEFAULT_LOCALE_TEXT, IMAGE_EDITOR_DEFAULT_QUICK_TOOLBAR, IMAGE_EDITOR_DEFAULT_TOOLBAR } from './image-editor/items.js';
10
+ export { FILTER_PRESETS as IMAGE_EDITOR_FILTER_PRESETS, IMAGE_EDITOR_FILTERS } from './image-editor/adjust.js';
11
+ if (process.env.NODE_ENV !== 'production')
12
+ expectStylesheet('@salmonui/editors/image-editor', 'salmon-image-editor');
13
+ //# sourceMappingURL=image-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-editor.js","sourceRoot":"","sources":["../src/image-editor.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,iDAAiD;AACjD,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,gCAAgC,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC7I,OAAO,EAAE,cAAc,IAAI,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA6C/G,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAAE,gBAAgB,CAAC,gCAAgC,EAAE,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { InlineEditLocaleText, InlineEditProps } from './types.js';
3
+ /** English defaults of `localeText`. */
4
+ export declare const INLINE_EDIT_DEFAULT_LOCALE_TEXT: InlineEditLocaleText;
5
+ export declare function InlineEdit<T = string>(props: InlineEditProps<T>): ReactElement;
6
+ //# sourceMappingURL=InlineEdit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InlineEdit.d.ts","sourceRoot":"","sources":["../../src/inline-edit/InlineEdit.tsx"],"names":[],"mappings":"AASA,OAAO,EAA2I,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAC;AAUnM,OAAO,KAAK,EAIV,oBAAoB,EACpB,eAAe,EAIhB,MAAM,YAAY,CAAC;AAEpB,wCAAwC;AACxC,eAAO,MAAM,+BAA+B,EAAE,oBAO5C,CAAC;AAyBH,wBAAgB,UAAU,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,YAAY,CAgb9E"}
@@ -0,0 +1,340 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // InlineEdit. A small local
4
+ // state machine, not an engine store: idle -> editing -> (validating) ->
5
+ // (saving) -> idle | error. The draft exists only while editing; an idle
6
+ // InlineEdit renders a button (or a span and an edit button) and a hidden
7
+ // input with `name`. Popover mode mounts the editor in the shared overlay
8
+ // primitive after hydration; nothing transient lives in React state.
9
+ import { useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
10
+ import { NO_ERRORS } from '@salmonui/core/validation';
11
+ import { Button } from '@salmonui/buttons/button';
12
+ import { useControllableState } from '@salmonui/core/internal/controllable';
13
+ import { useLocale, useLocaleText } from '@salmonui/core/internal/locale';
14
+ import { focusFirst } from '@salmonui/core/internal/focus-scope';
15
+ import { portalScopeOf } from '@salmonui/core/internal/modal-host';
16
+ import { Overlay } from '@salmonui/core/internal/overlay';
17
+ import { pressSource } from '@salmonui/core/internal/press';
18
+ import { compileInlineValidation, runValidation } from './validate.js';
19
+ /** English defaults of `localeText`. */
20
+ export const INLINE_EDIT_DEFAULT_LOCALE_TEXT = Object.freeze({
21
+ save: 'Save',
22
+ cancel: 'Cancel',
23
+ edit: 'Edit',
24
+ empty: 'Empty',
25
+ saving: 'Saving',
26
+ saveFailed: 'The value could not be saved.',
27
+ });
28
+ const isEmpty = (value) => value === null || value === undefined || value === '';
29
+ const textOf = (value) => (isEmpty(value) ? '' : String(value));
30
+ const cx = (...names) => names.filter(Boolean).join(' ');
31
+ function cancellable(base) {
32
+ let prevented = false;
33
+ return {
34
+ ...base,
35
+ get defaultPrevented() {
36
+ return prevented;
37
+ },
38
+ preventDefault() {
39
+ prevented = true;
40
+ },
41
+ };
42
+ }
43
+ const PENCIL = (_jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M11.5 1.8 14.2 4.5 5.4 13.3 2 14l.7-3.4z", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinejoin: "round" }) }));
44
+ export function InlineEdit(props) {
45
+ const { value: valueProp, defaultValue, save: saveAction, mode = 'popover', trigger = 'click', blurAction = 'save', saveOnEnter = true, showActions = true, renderActions, validation, placeholder, renderPreview, label, editing: editingProp, defaultEditing, onEditingChange, disabled = false, name, popoverProps, className, style, classNames, styles, ref, children, onBeforeEditStart, onEditStart, onBeforeSave, onSave, onSaveError, onBeforeEditCancel, onEditCancel, onDraftChange, localeText, ...rest } = props;
46
+ const locale = { ...INLINE_EDIT_DEFAULT_LOCALE_TEXT, ...useLocaleText('inlineEdit', localeText) };
47
+ const [saved, setSaved] = useControllableState(valueProp, (defaultValue ?? ''), undefined, 'InlineEdit value');
48
+ const [editing, setEditing] = useControllableState(editingProp, defaultEditing ?? false, onEditingChange, 'InlineEdit editing');
49
+ const [draft, setDraftState] = useState(null);
50
+ const [errors, setErrors] = useState(NO_ERRORS);
51
+ const [pending, setPending] = useState(false);
52
+ const [saveError, setSaveError] = useState(null);
53
+ // Where the popover mounts (the nearest theme scope) and its direction, read at start time.
54
+ const [host, setHost] = useState(null);
55
+ // An edit closed from outside (controlled `editing`) drops its draft.
56
+ const [wasEditing, setWasEditing] = useState(editing);
57
+ if (wasEditing !== editing) {
58
+ setWasEditing(editing);
59
+ if (!editing) {
60
+ setDraftState(null);
61
+ setErrors(NO_ERRORS);
62
+ setSaveError(null);
63
+ setPending(false);
64
+ }
65
+ }
66
+ // The rule messages and their plural forms follow the nearest LocaleProvider.
67
+ const validationText = useLocaleText('validation', undefined);
68
+ const pluralLocale = useLocale(undefined);
69
+ const validator = useMemo(() => compileInlineValidation(validation, validationText, pluralLocale), [validation, validationText, pluralLocale]);
70
+ const current = draft ? draft.v : saved;
71
+ const id = useId();
72
+ const inputId = `${id}-input`;
73
+ const errorId = `${id}-error`;
74
+ const rootRef = useRef(null);
75
+ const previewRef = useRef(null);
76
+ const editorRef = useRef(null);
77
+ const abortRef = useRef(null);
78
+ const busy = useRef(false);
79
+ const restoreFocus = useRef(false);
80
+ const draftRef = useRef(null);
81
+ const pressInside = useRef(false);
82
+ useEffect(() => () => {
83
+ abortRef.current?.abort();
84
+ }, []);
85
+ // Focus moves into the editor on start and back to the preview after save or cancel.
86
+ useLayoutEffect(() => {
87
+ if (editing) {
88
+ const editor = editorRef.current;
89
+ if (editor && !editor.contains(editor.ownerDocument.activeElement))
90
+ focusFirst(editor);
91
+ }
92
+ else if (restoreFocus.current) {
93
+ restoreFocus.current = false;
94
+ previewRef.current?.focus();
95
+ }
96
+ }, [editing]);
97
+ // The latest draft for handlers: a field may emit in the same event that commits (NumberField clamps on blur).
98
+ useLayoutEffect(() => {
99
+ draftRef.current = draft;
100
+ }, [draft]);
101
+ // Any press clears the flag first (document capture); the editor's capture handler sets it again.
102
+ useEffect(() => {
103
+ if (!editing)
104
+ return;
105
+ const doc = rootRef.current?.ownerDocument;
106
+ if (!doc)
107
+ return;
108
+ const onPress = () => {
109
+ pressInside.current = false;
110
+ };
111
+ doc.addEventListener('pointerdown', onPress, true);
112
+ return () => doc.removeEventListener('pointerdown', onPress, true);
113
+ }, [editing]);
114
+ const setBusy = (next) => {
115
+ busy.current = next;
116
+ setPending(next);
117
+ };
118
+ const finish = (reason, source, trigger) => {
119
+ const editor = editorRef.current;
120
+ const active = editor?.ownerDocument.activeElement;
121
+ restoreFocus.current = trigger !== 'blur' && (!active || active === editor?.ownerDocument.body || Boolean(editor?.contains(active)));
122
+ setDraftState(null);
123
+ setErrors(NO_ERRORS);
124
+ setSaveError(null);
125
+ setEditing(false, Object.freeze({ source, reason }));
126
+ };
127
+ const startEdit = (source) => {
128
+ if (disabled || editing)
129
+ return;
130
+ if (onBeforeEditStart) {
131
+ const event = cancellable({ source });
132
+ onBeforeEditStart(event);
133
+ if (event.defaultPrevented)
134
+ return;
135
+ }
136
+ const root = rootRef.current;
137
+ if (root && mode === 'popover') {
138
+ setHost({ container: portalScopeOf(root), dir: root.ownerDocument.defaultView?.getComputedStyle(root).direction ?? 'ltr' });
139
+ }
140
+ setDraftState(null);
141
+ setErrors(NO_ERRORS);
142
+ setSaveError(null);
143
+ setEditing(true, Object.freeze({ source, reason: 'start' }));
144
+ onEditStart?.(Object.freeze({ source }));
145
+ };
146
+ const validateValue = async (value) => {
147
+ const result = runValidation(validator, value);
148
+ if (!(result instanceof Promise))
149
+ return result;
150
+ setBusy(true);
151
+ try {
152
+ return await result;
153
+ }
154
+ finally {
155
+ setBusy(false);
156
+ }
157
+ };
158
+ const commit = async (trigger, source) => {
159
+ if (!editing || busy.current)
160
+ return false;
161
+ const value = draftRef.current ? draftRef.current.v : saved;
162
+ const found = await validateValue(value);
163
+ setErrors(found);
164
+ if (found.length)
165
+ return false;
166
+ const base = { value, previousValue: saved, source, trigger };
167
+ if (onBeforeSave) {
168
+ const event = cancellable(base);
169
+ onBeforeSave(event);
170
+ if (event.defaultPrevented)
171
+ return false;
172
+ }
173
+ if (saveAction) {
174
+ const controller = new AbortController();
175
+ abortRef.current = controller;
176
+ setSaveError(null);
177
+ setBusy(true);
178
+ try {
179
+ await saveAction(value, { signal: controller.signal });
180
+ }
181
+ catch (error) {
182
+ if (controller.signal.aborted)
183
+ return false;
184
+ abortRef.current = null;
185
+ setBusy(false);
186
+ // A rejection keeps the editor open with the error, announced politely.
187
+ setSaveError(locale.saveFailed);
188
+ onSaveError?.(Object.freeze({ value, error }));
189
+ return false;
190
+ }
191
+ if (controller.signal.aborted)
192
+ return false;
193
+ abortRef.current = null;
194
+ setBusy(false);
195
+ }
196
+ setSaved(value);
197
+ finish('save', source, trigger);
198
+ onSave?.(Object.freeze(base));
199
+ return true;
200
+ };
201
+ const cancel = (trigger, source) => {
202
+ if (!editing)
203
+ return;
204
+ const base = { value: current, source, trigger };
205
+ if (onBeforeEditCancel) {
206
+ const event = cancellable(base);
207
+ onBeforeEditCancel(event);
208
+ if (event.defaultPrevented)
209
+ return;
210
+ }
211
+ abortRef.current?.abort();
212
+ abortRef.current = null;
213
+ setBusy(false);
214
+ finish('cancel', source, trigger);
215
+ onEditCancel?.(Object.freeze(base));
216
+ };
217
+ const setValue = (next) => {
218
+ if (busy.current)
219
+ return;
220
+ const previousValue = draftRef.current ? draftRef.current.v : saved;
221
+ draftRef.current = { v: next };
222
+ setDraftState(draftRef.current);
223
+ if (!Object.is(next, previousValue))
224
+ onDraftChange?.(Object.freeze({ value: next, previousValue }));
225
+ };
226
+ useImperativeHandle(ref, () => ({
227
+ get element() {
228
+ return rootRef.current;
229
+ },
230
+ startEdit: () => startEdit('api'),
231
+ save: () => commit('api', 'api'),
232
+ cancelEdit: () => cancel('api', 'api'),
233
+ validate: async () => {
234
+ const found = await validateValue(editing ? current : saved);
235
+ if (editing)
236
+ setErrors(found);
237
+ return found;
238
+ },
239
+ }));
240
+ const onEditorKeyDown = (event) => {
241
+ if (event.key === 'Escape' && !event.defaultPrevented) {
242
+ // Escape inside a field's own overlay (it bubbles here through the portal) closes that overlay only.
243
+ const overlay = event.target.closest('[data-salmon-overlay]');
244
+ if (overlay && !overlay.contains(event.currentTarget))
245
+ return;
246
+ event.preventDefault();
247
+ cancel('escape', 'keyboard');
248
+ }
249
+ };
250
+ const onEditorBlur = (event) => {
251
+ const next = event.relatedTarget;
252
+ // Focus moving inside the editor, or into a popup the editor opened (a picker), is not a blur.
253
+ if (busy.current || (next && (event.currentTarget.contains(next) || next.closest('[data-salmon-overlay]'))))
254
+ return;
255
+ if (!next && pressInside.current) {
256
+ // A press on a non-focusable part of the editor or of a field's portaled popup drops focus
257
+ // to the body. The edit continues, and focus comes back so Escape and Tab keep working.
258
+ pressInside.current = false;
259
+ const target = event.target;
260
+ const doc = target.ownerDocument;
261
+ setTimeout(() => {
262
+ if (doc.activeElement && doc.activeElement !== doc.body)
263
+ return;
264
+ if (target.isConnected)
265
+ target.focus({ preventScroll: true });
266
+ else if (editorRef.current)
267
+ focusFirst(editorRef.current);
268
+ }, 0);
269
+ return;
270
+ }
271
+ if (blurAction === 'save')
272
+ void commit('blur', 'pointer');
273
+ else if (blurAction === 'cancel')
274
+ cancel('blur', 'pointer');
275
+ };
276
+ const invalid = errors.length > 0;
277
+ const inputProps = {
278
+ id: inputId,
279
+ value: textOf(current),
280
+ onChange: (event) => setValue(event.target.value),
281
+ onKeyDown: (event) => {
282
+ if (event.key !== 'Enter' || !saveOnEnter || event.nativeEvent.isComposing)
283
+ return;
284
+ // A multiline editor keeps Enter for new lines and saves with Mod+Enter.
285
+ if (event.target.tagName === 'TEXTAREA' && !(event.ctrlKey || event.metaKey))
286
+ return;
287
+ event.preventDefault();
288
+ void commit('enter', 'keyboard');
289
+ },
290
+ 'aria-invalid': invalid || undefined,
291
+ 'aria-describedby': invalid || saveError ? errorId : undefined,
292
+ 'aria-label': label,
293
+ readOnly: pending,
294
+ autoFocus: true,
295
+ };
296
+ const context = {
297
+ value: current,
298
+ setValue,
299
+ inputProps,
300
+ save: () => void commit('api', 'api'),
301
+ cancel: () => cancel('api', 'api'),
302
+ pending,
303
+ errors,
304
+ };
305
+ const actionContext = {
306
+ save: () => void commit('actions', 'api'),
307
+ cancel: () => cancel('actions', 'api'),
308
+ pending,
309
+ };
310
+ const empty = isEmpty(saved);
311
+ const shownPlaceholder = placeholder ?? locale.empty;
312
+ const preview = renderPreview ? renderPreview({ value: saved, placeholder: shownPlaceholder }) : empty ? shownPlaceholder : textOf(saved);
313
+ const popover = mode === 'popover';
314
+ const editor = editing ? (_jsxs("span", { ref: editorRef, className: cx('salmon-inline-edit-editor', classNames?.editor), style: styles?.editor, "aria-busy": pending || undefined, "data-pending": pending ? '' : undefined, onKeyDown: onEditorKeyDown, onBlur: onEditorBlur,
315
+ // React events bubble through portals, so these also see presses in a field's popup.
316
+ onPointerDownCapture: () => {
317
+ pressInside.current = true;
318
+ }, onKeyDownCapture: () => {
319
+ pressInside.current = false;
320
+ }, children: [_jsx("span", { className: "salmon-inline-edit-field", children: children ? children(context) : _jsx("input", { type: "text", className: "salmon-inline-edit-input", ...inputProps }) }), showActions ? (_jsx("span", { className: cx('salmon-inline-edit-actions', classNames?.actions), style: styles?.actions, children: renderActions ? (renderActions(actionContext)) : (_jsxs(_Fragment, { children: [_jsx(Button, { tone: "primary", loading: pending, loadingLabel: locale.saving, onClick: (e) => void commit('actions', pressSource(e)), children: locale.save }), _jsx(Button, { variant: "outline", onClick: (e) => cancel('actions', pressSource(e)), children: locale.cancel })] })) })) : null, invalid || saveError ? (_jsx("span", { id: errorId, className: cx('salmon-inline-edit-error', classNames?.error), style: styles?.error, children: saveError ?? errors.join(' ') })) : null] })) : null;
321
+ let display = null;
322
+ if (!editing || popover) {
323
+ const previewClass = cx('salmon-inline-edit-preview', classNames?.preview);
324
+ const expanded = popover && trigger !== 'editButton' ? editing : undefined;
325
+ const editButton = (_jsx(Button, { ref: trigger === 'editButton' ? previewRef : undefined, className: "salmon-inline-edit-edit-button", variant: "ghost", size: "sm", iconOnly: true, "aria-label": label ? `${locale.edit} ${label}` : locale.edit, "aria-haspopup": popover ? 'dialog' : undefined, "aria-expanded": popover ? editing : undefined, disabled: disabled,
326
+ // With trigger="doubleClick" the button shows only on coarse pointers (CSS).
327
+ tabIndex: trigger === 'doubleClick' ? -1 : undefined, onClick: (e) => startEdit(pressSource(e)), children: PENCIL }));
328
+ display =
329
+ trigger === 'editButton' ? (_jsxs(_Fragment, { children: [_jsx("span", { className: previewClass, style: styles?.preview, "data-empty": empty ? '' : undefined, children: preview }), editButton] })) : (_jsxs(_Fragment, { children: [_jsxs("button", { ref: previewRef, type: "button", className: previewClass, style: styles?.preview, "data-empty": empty ? '' : undefined, "aria-haspopup": popover ? 'dialog' : undefined, "aria-expanded": expanded, "aria-disabled": disabled || undefined, onClick: (e) => {
330
+ if (disabled)
331
+ return;
332
+ const source = pressSource(e);
333
+ // Double-click mode: a pointer click only focuses; Enter and Space (detail 0) start editing.
334
+ if (trigger === 'click' || source === 'keyboard')
335
+ startEdit(source);
336
+ }, onDoubleClick: trigger === 'doubleClick' ? () => startEdit('pointer') : undefined, children: [label ? _jsx("span", { className: "salmon-inline-edit-label", children: `${label}: ` }) : null, preview] }), trigger === 'doubleClick' ? editButton : null] }));
337
+ }
338
+ return (_jsxs("span", { ...rest, ref: rootRef, className: cx('salmon-inline-edit', className), style: style, "data-mode": mode, "data-trigger": trigger, "data-editing": editing ? '' : undefined, "data-disabled": disabled ? '' : undefined, children: [name ? _jsx("input", { type: "hidden", name: name, value: textOf(saved) }) : null, display, editing && !popover ? editor : null, editing && popover ? (_jsx(Overlay, { anchor: rootRef, container: host?.container, dir: host?.dir, role: "dialog", "aria-label": label ?? locale.edit, className: "salmon-inline-edit-popover", placement: popoverProps?.placement ?? 'bottom-start', offset: popoverProps?.offset ?? 4, focus: { autoFocus: false, restoreFocus: false }, children: editor })) : null, _jsx("span", { className: "salmon-inline-edit-status", role: "status", children: pending ? locale.saving : (saveError ?? '') })] }));
339
+ }
340
+ //# sourceMappingURL=InlineEdit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InlineEdit.js","sourceRoot":"","sources":["../../src/inline-edit/InlineEdit.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,4BAA4B;AAC5B,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,qEAAqE;AAErE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAA2F,MAAM,OAAO,CAAC;AACnM,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,C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GAAG,EACd,IAAI,EAAC,QAAQ,gBACD,KAAK,IAAI,MAAM,CAAC,IAAI,EAChC,SAAS,EAAC,4BAA4B,EACtC,SAAS,EAAE,YAAY,EAAE,SAAS,IAAI,cAAc,EACpD,MAAM,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC,EACjC,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAE/C,MAAM,GACC,CACX,CAAC,CAAC,CAAC,IAAI,EACR,eAAM,SAAS,EAAC,2BAA2B,EAAC,IAAI,EAAC,QAAQ,YACtD,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,GACvC,IACF,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,177 @@
1
+ import type { CSSProperties, HTMLAttributes, KeyboardEvent, ReactNode, Ref } from 'react';
2
+ import type { ColumnValidation } from '@salmonui/core/validation';
3
+ import type { Placement } from '@salmonui/core/internal/position';
4
+ /** Input that caused a lifecycle event. */
5
+ export type InlineEditSource = 'pointer' | 'keyboard' | 'touch' | 'api';
6
+ /** What ended an edit: the action buttons, Enter, Escape, focus leaving, or a ref method. */
7
+ export type InlineEditTrigger = 'actions' | 'enter' | 'escape' | 'blur' | 'api';
8
+ /** Custom validator of `validation.validate`: an error message, or null / undefined / true when valid (false uses the default message). May be async. */
9
+ export type InlineEditValidator<T> = (value: T) => string | boolean | null | undefined | PromiseLike<string | boolean | null | undefined>;
10
+ /**
11
+ * Validation rules: the Data Grid `column.validation` vocabulary,
12
+ * evaluated by `@salmonui/core/validation`. Each rule value is the
13
+ * argument or `[argument, message]`.
14
+ */
15
+ export type InlineEditValidation<T = unknown> = Omit<ColumnValidation, 'validate'> & {
16
+ readonly validate?: InlineEditValidator<T> | readonly [InlineEditValidator<T>, string] | readonly InlineEditValidator<T>[];
17
+ };
18
+ /** A cancellable event (`preventDefault()` vetoes the step). */
19
+ export interface InlineEditCancellable {
20
+ readonly defaultPrevented: boolean;
21
+ preventDefault(): void;
22
+ }
23
+ export interface InlineEditStartEvent {
24
+ readonly source: InlineEditSource;
25
+ }
26
+ export interface InlineEditSaveEvent<T> {
27
+ /** The value being saved (the draft). */
28
+ readonly value: T;
29
+ /** The saved value before this edit. */
30
+ readonly previousValue: T;
31
+ readonly source: InlineEditSource;
32
+ readonly trigger: InlineEditTrigger;
33
+ }
34
+ export interface InlineEditCancelEvent<T> {
35
+ /** The discarded draft. */
36
+ readonly value: T;
37
+ readonly source: InlineEditSource;
38
+ readonly trigger: InlineEditTrigger;
39
+ }
40
+ export interface InlineEditDraftChangeEvent<T> {
41
+ readonly value: T;
42
+ readonly previousValue: T;
43
+ }
44
+ export interface InlineEditSaveErrorEvent<T> {
45
+ readonly value: T;
46
+ readonly error: unknown;
47
+ }
48
+ /** Second argument of `onEditingChange` (frozen). */
49
+ export interface InlineEditEditingChangeEvent {
50
+ readonly source: InlineEditSource;
51
+ readonly reason: 'start' | 'save' | 'cancel';
52
+ }
53
+ /** Props for the edit element: spread them on an input or pass them to a Salmon field. */
54
+ export interface InlineEditInputProps {
55
+ readonly id: string;
56
+ readonly value: string;
57
+ readonly onChange: (event: {
58
+ readonly target: {
59
+ readonly value: string;
60
+ };
61
+ }) => void;
62
+ readonly onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
63
+ readonly 'aria-invalid': true | undefined;
64
+ readonly 'aria-describedby': string | undefined;
65
+ readonly 'aria-label': string | undefined;
66
+ readonly readOnly: boolean;
67
+ readonly autoFocus: true;
68
+ }
69
+ /** Argument of the `children` render prop. */
70
+ export interface InlineEditRenderContext<T> {
71
+ /** The draft value. */
72
+ readonly value: T;
73
+ /** Replaces the draft. */
74
+ readonly setValue: (value: T) => void;
75
+ /** Wiring for a text-like input (`value` is the draft as a string). */
76
+ readonly inputProps: InlineEditInputProps;
77
+ readonly save: () => void;
78
+ readonly cancel: () => void;
79
+ /** True while `save` (or async validation) is pending. */
80
+ readonly pending: boolean;
81
+ /** Validation messages of the draft (empty when valid). */
82
+ readonly errors: readonly string[];
83
+ }
84
+ export interface InlineEditActionsContext {
85
+ readonly save: () => void;
86
+ readonly cancel: () => void;
87
+ readonly pending: boolean;
88
+ }
89
+ /** Text of the built-in parts. */
90
+ export interface InlineEditLocaleText {
91
+ readonly save: string;
92
+ readonly cancel: string;
93
+ readonly edit: string;
94
+ readonly empty: string;
95
+ readonly saving: string;
96
+ readonly saveFailed: string;
97
+ }
98
+ export type {} from '@salmonui/core/locale';
99
+ declare module '@salmonui/core/locale' {
100
+ interface LocaleCatalog {
101
+ readonly inlineEdit?: Partial<InlineEditLocaleText> | undefined;
102
+ }
103
+ }
104
+ /** Ref handle: the Data Grid edit method names. */
105
+ export interface InlineEditApi {
106
+ /** The root element. */
107
+ readonly element: HTMLSpanElement | null;
108
+ startEdit(): void;
109
+ /** Saves the draft; resolves to true when the value was saved. */
110
+ save(): Promise<boolean>;
111
+ cancelEdit(): void;
112
+ /** Validates the draft (or the saved value when idle) and resolves to the error list. */
113
+ validate(): Promise<readonly string[]>;
114
+ }
115
+ export type InlineEditPart = 'preview' | 'editor' | 'actions' | 'error';
116
+ type RootProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'defaultValue' | 'onChange' | 'placeholder' | 'className' | 'style'>;
117
+ export interface InlineEditProps<T = string> extends RootProps {
118
+ /** Saved value (controlled). */
119
+ readonly value?: T | undefined;
120
+ /** Initial saved value when uncontrolled. Default `''`. */
121
+ readonly defaultValue?: T | undefined;
122
+ /** Persists a value. May return a promise: pending state, abort on cancel or unmount, rejection keeps editing. */
123
+ readonly save?: ((value: T, options: {
124
+ readonly signal: AbortSignal;
125
+ }) => void | PromiseLike<void>) | undefined;
126
+ /** `'popover'` (default) opens the editor in a non-modal dialog anchored to the preview; `'inline'` replaces the preview. */
127
+ readonly mode?: 'inline' | 'popover' | undefined;
128
+ /** What starts editing. Default `'click'`. */
129
+ readonly trigger?: 'click' | 'doubleClick' | 'editButton' | undefined;
130
+ /** What focus leaving the editor does. Default `'save'`. */
131
+ readonly blurAction?: 'save' | 'cancel' | 'keep' | undefined;
132
+ /** Enter saves (Mod+Enter in a textarea). Default true. */
133
+ readonly saveOnEnter?: boolean | undefined;
134
+ /** Shows the Save and Cancel buttons. Default true. */
135
+ readonly showActions?: boolean | undefined;
136
+ /** Replaces the default actions. */
137
+ readonly renderActions?: ((context: InlineEditActionsContext) => ReactNode) | undefined;
138
+ readonly validation?: InlineEditValidation<T> | undefined;
139
+ /** Shown when the value is empty. Default `localeText.empty`. */
140
+ readonly placeholder?: ReactNode;
141
+ /** Display state content. Default `String(value)`. */
142
+ readonly renderPreview?: ((context: {
143
+ readonly value: T;
144
+ readonly placeholder: ReactNode;
145
+ }) => ReactNode) | undefined;
146
+ /** Field label: the accessible name of the preview and the editor. */
147
+ readonly label?: string | undefined;
148
+ /** Editing state. */
149
+ readonly editing?: boolean | undefined;
150
+ readonly defaultEditing?: boolean | undefined;
151
+ readonly onEditingChange?: ((editing: boolean, event: InlineEditEditingChangeEvent) => void) | undefined;
152
+ readonly disabled?: boolean | undefined;
153
+ /** Form field name: a hidden input carries the saved value. */
154
+ readonly name?: string | undefined;
155
+ /** Popover placement and offset. */
156
+ readonly popoverProps?: {
157
+ readonly placement?: Placement | undefined;
158
+ readonly offset?: number | undefined;
159
+ } | undefined;
160
+ readonly localeText?: Partial<InlineEditLocaleText> | undefined;
161
+ readonly className?: string | undefined;
162
+ readonly style?: CSSProperties | undefined;
163
+ readonly classNames?: Partial<Record<InlineEditPart, string>> | undefined;
164
+ readonly styles?: Partial<Record<InlineEditPart, CSSProperties>> | undefined;
165
+ readonly ref?: Ref<InlineEditApi> | undefined;
166
+ /** The edit element. Default: a text input. */
167
+ readonly children?: ((context: InlineEditRenderContext<T>) => ReactNode) | undefined;
168
+ readonly onBeforeEditStart?: ((event: InlineEditStartEvent & InlineEditCancellable) => void) | undefined;
169
+ readonly onEditStart?: ((event: InlineEditStartEvent) => void) | undefined;
170
+ readonly onBeforeSave?: ((event: InlineEditSaveEvent<T> & InlineEditCancellable) => void) | undefined;
171
+ readonly onSave?: ((event: InlineEditSaveEvent<T>) => void) | undefined;
172
+ readonly onSaveError?: ((event: InlineEditSaveErrorEvent<T>) => void) | undefined;
173
+ readonly onBeforeEditCancel?: ((event: InlineEditCancelEvent<T> & InlineEditCancellable) => void) | undefined;
174
+ readonly onEditCancel?: ((event: InlineEditCancelEvent<T>) => void) | undefined;
175
+ readonly onDraftChange?: ((event: InlineEditDraftChangeEvent<T>) => void) | undefined;
176
+ }
177
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/inline-edit/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,2CAA2C;AAC3C,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,CAAC;AAExE,6FAA6F;AAC7F,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAEhF,yJAAyJ;AACzJ,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAE1I;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IACnF,QA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file":"types.js","sourceRoot":"","sources":["../../src/inline-edit/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { type ValidationMessageText } from '@salmonui/core/validation';
2
+ import type { InlineEditValidation } from './types.js';
3
+ export interface InlineEditValidator {
4
+ /** Built-in rules: the first message, or an empty list. */
5
+ readonly sync: (value: unknown) => readonly string[];
6
+ /** Custom rules, or null when there are none. */
7
+ readonly custom: ((value: unknown) => string | null | PromiseLike<string | null>) | null;
8
+ }
9
+ /** The shared `validation` family of a `LocaleProvider` (`validationRequired`, `validationMin`, ...). */
10
+ export type ValidationFamilyText = {
11
+ readonly [K in keyof ValidationMessageText as `validation${Capitalize<K>}`]?: ValidationMessageText[K];
12
+ };
13
+ /** Compiles `rules` with the messages of `text` over English; `locale` chooses their plural forms. `rules.messages` wins. */
14
+ export declare function compileInlineValidation(rules: InlineEditValidation<never> | undefined, text?: ValidationFamilyText, locale?: string): InlineEditValidator | null;
15
+ /** Runs every rule; returns the errors synchronously when no custom rule is async. */
16
+ export declare function runValidation(validator: InlineEditValidator | null, value: unknown): readonly string[] | Promise<readonly string[]>;
17
+ //# sourceMappingURL=validate.d.ts.map