@sealpixel/ui 1.0.0-rc.20 → 1.0.0-rc.22

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 (70) hide show
  1. package/dist/components/editor/empty-state.d.ts +14 -0
  2. package/dist/components/editor/empty-state.js +38 -0
  3. package/dist/components/editor/empty-state.js.map +1 -0
  4. package/dist/components/editor/json-attribute.d.ts +5 -0
  5. package/dist/components/editor/json-attribute.js +18 -0
  6. package/dist/components/editor/json-attribute.js.map +1 -0
  7. package/dist/components/editor/panel-fit.d.ts +20 -0
  8. package/dist/components/editor/panel-fit.js +60 -0
  9. package/dist/components/editor/panel-fit.js.map +1 -0
  10. package/dist/components/editor/styles.d.ts +2 -0
  11. package/dist/components/editor/styles.js +697 -0
  12. package/dist/components/editor/styles.js.map +1 -0
  13. package/dist/components/editor/toast.d.ts +8 -0
  14. package/dist/components/editor/toast.js +21 -0
  15. package/dist/components/editor/toast.js.map +1 -0
  16. package/dist/components/sealpixel-editor.d.ts +9 -44
  17. package/dist/components/sealpixel-editor.js +45 -888
  18. package/dist/components/sealpixel-editor.js.map +1 -1
  19. package/dist/components/sealpixel-stage.js +11 -2
  20. package/dist/components/sealpixel-stage.js.map +1 -1
  21. package/dist/controllers/history-shortcuts-controller.d.ts +18 -0
  22. package/dist/controllers/history-shortcuts-controller.js +68 -0
  23. package/dist/controllers/history-shortcuts-controller.js.map +1 -0
  24. package/dist/locales/de.js +16 -0
  25. package/dist/locales/de.js.map +1 -1
  26. package/dist/locales/en.js +16 -0
  27. package/dist/locales/en.js.map +1 -1
  28. package/dist/locales/es.js +16 -0
  29. package/dist/locales/es.js.map +1 -1
  30. package/dist/locales/fr.js +16 -0
  31. package/dist/locales/fr.js.map +1 -1
  32. package/dist/locales/ja.js +16 -0
  33. package/dist/locales/ja.js.map +1 -1
  34. package/dist/locales/pt.js +16 -0
  35. package/dist/locales/pt.js.map +1 -1
  36. package/dist/tools/annotate.d.ts +58 -0
  37. package/dist/tools/annotate.js +136 -12
  38. package/dist/tools/annotate.js.map +1 -1
  39. package/dist/tools/assist.d.ts +3 -0
  40. package/dist/tools/assist.js +44 -9
  41. package/dist/tools/assist.js.map +1 -1
  42. package/dist/tools/crop-mask.d.ts +2 -0
  43. package/dist/tools/crop-mask.js +11 -0
  44. package/dist/tools/crop-mask.js.map +1 -1
  45. package/dist/tools/crop.d.ts +9 -0
  46. package/dist/tools/crop.js +117 -48
  47. package/dist/tools/crop.js.map +1 -1
  48. package/dist/tools/filter.js +41 -19
  49. package/dist/tools/filter.js.map +1 -1
  50. package/dist/tools/finetune.js +10 -7
  51. package/dist/tools/finetune.js.map +1 -1
  52. package/dist/tools/frame.js +10 -10
  53. package/dist/tools/frame.js.map +1 -1
  54. package/dist/tools/instance-state.d.ts +8 -0
  55. package/dist/tools/instance-state.js +32 -0
  56. package/dist/tools/instance-state.js.map +1 -0
  57. package/dist/tools/keys.d.ts +95 -3
  58. package/dist/tools/keys.js +135 -2
  59. package/dist/tools/keys.js.map +1 -1
  60. package/dist/tools/redact.d.ts +18 -10
  61. package/dist/tools/redact.js +233 -35
  62. package/dist/tools/redact.js.map +1 -1
  63. package/dist/tools/region-transform.d.ts +23 -14
  64. package/dist/tools/region-transform.js +45 -32
  65. package/dist/tools/region-transform.js.map +1 -1
  66. package/dist/tools/resize.js +11 -9
  67. package/dist/tools/resize.js.map +1 -1
  68. package/dist/tools/sticker.js +7 -3
  69. package/dist/tools/sticker.js.map +1 -1
  70. package/package.json +4 -4
@@ -0,0 +1,14 @@
1
+ import type { SessionState } from '@sealpixel/core';
2
+ import { type TemplateResult } from 'lit';
3
+ import type { I18n } from '../../i18n.js';
4
+ export interface EmptyStateOptions {
5
+ state: SessionState | null;
6
+ t: I18n['t'];
7
+ /** Whether a file is dragged over the drop area. */
8
+ dragover: boolean;
9
+ setDragover: (dragover: boolean) => void;
10
+ /** Called with the chosen or dropped files. */
11
+ onFiles: (files: FileList | null) => void;
12
+ }
13
+ /** What the stage area shows without an image: the loading mark, or the drop area and file picker. */
14
+ export declare function renderEmpty({ state, t, dragover, setDragover, onFiles, }: EmptyStateOptions): TemplateResult;
@@ -0,0 +1,38 @@
1
+ import { html } from 'lit';
2
+ /** What the stage area shows without an image: the loading mark, or the drop area and file picker. */
3
+ export function renderEmpty({ state, t, dragover, setDragover, onFiles, }) {
4
+ if (state?.status === 'loading') {
5
+ return html `<div class="empty loading" part="empty" role="status">
6
+ <svg class="mark" viewBox="0 0 32 32" aria-hidden="true">
7
+ <rect x="3" y="3" width="26" height="26" rx="5" fill="none" stroke="currentColor" stroke-width="2" />
8
+ <rect class="core" x="11" y="11" width="10" height="10" rx="1.5" fill="currentColor" />
9
+ </svg>
10
+ <p>${t('editor.loading')}</p>
11
+ </div>`;
12
+ }
13
+ return html `<div
14
+ class="empty ${dragover ? 'dragover' : ''}"
15
+ part="empty"
16
+ @dragover=${(e) => {
17
+ e.preventDefault();
18
+ setDragover(true);
19
+ }}
20
+ @dragleave=${() => {
21
+ setDragover(false);
22
+ }}
23
+ @drop=${(e) => {
24
+ e.preventDefault();
25
+ setDragover(false);
26
+ onFiles(e.dataTransfer?.files ?? null);
27
+ }}
28
+ >
29
+ <p>${t('editor.empty')}</p>
30
+ <label>
31
+ <input class="visually-hidden" type="file" accept="image/png,image/jpeg,image/webp" @change=${(e) => onFiles(e.target.files)} />
32
+ <sealpixel-button variant="primary" @click=${(e) => e.currentTarget.previousElementSibling.click()}>
33
+ ${t('editor.choose')}
34
+ </sealpixel-button>
35
+ </label>
36
+ </div>`;
37
+ }
38
+ //# sourceMappingURL=empty-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-state.js","sourceRoot":"","sources":["../../../src/components/editor/empty-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAahD,sGAAsG;AACtG,MAAM,UAAU,WAAW,CAAC,EAC1B,KAAK,EACL,CAAC,EACD,QAAQ,EACR,WAAW,EACX,OAAO,GACW;IAClB,IAAI,KAAK,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,IAAI,CAAA;;;;;aAKF,CAAC,CAAC,gBAAgB,CAAC;aACnB,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAA;qBACQ,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;;kBAE7B,CAAC,CAAY,EAAE,EAAE;QAC3B,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;mBACY,GAAG,EAAE;QAChB,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;cACO,CAAC,CAAY,EAAE,EAAE;QACvB,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC;IACzC,CAAC;;WAEI,CAAC,CAAC,cAAc,CAAC;;sGAE0E,CAAC,CAAQ,EAAE,EAAE,CAAC,OAAO,CAAE,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC;qDAC5G,CAAC,CAAQ,EAAE,EAAE,CAAG,CAAC,CAAC,aAA6B,CAAC,sBAA2C,CAAC,KAAK,EAAE;YAC5I,CAAC,CAAC,eAAe,CAAC;;;WAGnB,CAAC;AACZ,CAAC","sourcesContent":["import type { SessionState } from '@sealpixel/core';\nimport { html, type TemplateResult } from 'lit';\nimport type { I18n } from '../../i18n.js';\n\nexport interface EmptyStateOptions {\n state: SessionState | null;\n t: I18n['t'];\n /** Whether a file is dragged over the drop area. */\n dragover: boolean;\n setDragover: (dragover: boolean) => void;\n /** Called with the chosen or dropped files. */\n onFiles: (files: FileList | null) => void;\n}\n\n/** What the stage area shows without an image: the loading mark, or the drop area and file picker. */\nexport function renderEmpty({\n state,\n t,\n dragover,\n setDragover,\n onFiles,\n}: EmptyStateOptions): TemplateResult {\n if (state?.status === 'loading') {\n return html`<div class=\"empty loading\" part=\"empty\" role=\"status\">\n <svg class=\"mark\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n <rect x=\"3\" y=\"3\" width=\"26\" height=\"26\" rx=\"5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" />\n <rect class=\"core\" x=\"11\" y=\"11\" width=\"10\" height=\"10\" rx=\"1.5\" fill=\"currentColor\" />\n </svg>\n <p>${t('editor.loading')}</p>\n </div>`;\n }\n return html`<div\n class=\"empty ${dragover ? 'dragover' : ''}\"\n part=\"empty\"\n @dragover=${(e: DragEvent) => {\n e.preventDefault();\n setDragover(true);\n }}\n @dragleave=${() => {\n setDragover(false);\n }}\n @drop=${(e: DragEvent) => {\n e.preventDefault();\n setDragover(false);\n onFiles(e.dataTransfer?.files ?? null);\n }}\n >\n <p>${t('editor.empty')}</p>\n <label>\n <input class=\"visually-hidden\" type=\"file\" accept=\"image/png,image/jpeg,image/webp\" @change=${(e: Event) => onFiles((e.target as HTMLInputElement).files)} />\n <sealpixel-button variant=\"primary\" @click=${(e: Event) => ((e.currentTarget as HTMLElement).previousElementSibling as HTMLInputElement).click()}>\n ${t('editor.choose')}\n </sealpixel-button>\n </label>\n </div>`;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /** `plugin-options='{"filter":{...}}'` attribute ↔ property. */
2
+ export declare function jsonAttribute<T extends object>(name: string): {
3
+ fromAttribute: (value: string | null) => T | null;
4
+ toAttribute: (value: T | null) => string | null;
5
+ };
@@ -0,0 +1,18 @@
1
+ /** `plugin-options='{"filter":{...}}'` attribute ↔ property. */
2
+ export function jsonAttribute(name) {
3
+ return {
4
+ fromAttribute: (value) => {
5
+ if (value === null || value.trim() === '')
6
+ return null;
7
+ try {
8
+ return JSON.parse(value);
9
+ }
10
+ catch {
11
+ console.warn(`[sealpixel] ${name} is not valid JSON`);
12
+ return null;
13
+ }
14
+ },
15
+ toAttribute: (value) => (value ? JSON.stringify(value) : null),
16
+ };
17
+ }
18
+ //# sourceMappingURL=json-attribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-attribute.js","sourceRoot":"","sources":["../../../src/components/editor/json-attribute.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,UAAU,aAAa,CAAmB,IAAY;IAC1D,OAAO;QACL,aAAa,EAAE,CAAC,KAAoB,EAAE,EAAE;YACtC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC;YACvD,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,oBAAoB,CAAC,CAAC;gBACtD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,WAAW,EAAE,CAAC,KAAe,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACzE,CAAC;AACJ,CAAC","sourcesContent":["/** `plugin-options='{\"filter\":{...}}'` attribute ↔ property. */\nexport function jsonAttribute<T extends object>(name: string) {\n return {\n fromAttribute: (value: string | null) => {\n if (value === null || value.trim() === '') return null;\n try {\n return JSON.parse(value) as T;\n } catch {\n console.warn(`[sealpixel] ${name} is not valid JSON`);\n return null;\n }\n },\n toAttribute: (value: T | null) => (value ? JSON.stringify(value) : null),\n };\n}\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Collapses the settings bar when the open tool has nothing to put in it.
3
+ *
4
+ * A tool renders its own structure, and a structure can hold nothing: crop
5
+ * with `rotation`, `flip` and `reset` off and a single enforced aspect emits
6
+ * two empty wrappers. The bar is a fixed height on purpose — see `.panel` —
7
+ * so that reserved an empty bordered surface and took the same height off
8
+ * the stage. On the landing page's avatar card that was 240 px of nothing
9
+ * against a 178 px stage, and the photo rendered at 10 percent.
10
+ *
11
+ * Read from the DOM rather than asked of the tool: every tool would
12
+ * otherwise have to declare it, and a tool whose panel empties out only
13
+ * under some options would get it wrong.
14
+ *
15
+ * Not measured by size either. The empty wrappers still lay out — the row
16
+ * is 8px from its own gap and the group 4px from its border — so a
17
+ * bounding box tells content and scaffolding apart not at all. What counts
18
+ * is a control or a word: a custom element, a form control, or any text.
19
+ */
20
+ export declare function syncPanelFill(panel: HTMLElement): void;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * What makes a settings bar worth its height: a control, or anything that
3
+ * draws. Plain `div`s are the tools' own scaffolding and never count.
4
+ */
5
+ const PANEL_CONTENT = 'select, input, textarea, button, img, svg, canvas, a, [role]';
6
+ /**
7
+ * Collapses the settings bar when the open tool has nothing to put in it.
8
+ *
9
+ * A tool renders its own structure, and a structure can hold nothing: crop
10
+ * with `rotation`, `flip` and `reset` off and a single enforced aspect emits
11
+ * two empty wrappers. The bar is a fixed height on purpose — see `.panel` —
12
+ * so that reserved an empty bordered surface and took the same height off
13
+ * the stage. On the landing page's avatar card that was 240 px of nothing
14
+ * against a 178 px stage, and the photo rendered at 10 percent.
15
+ *
16
+ * Read from the DOM rather than asked of the tool: every tool would
17
+ * otherwise have to declare it, and a tool whose panel empties out only
18
+ * under some options would get it wrong.
19
+ *
20
+ * Not measured by size either. The empty wrappers still lay out — the row
21
+ * is 8px from its own gap and the group 4px from its border — so a
22
+ * bounding box tells content and scaffolding apart not at all. What counts
23
+ * is a control or a word: a custom element, a form control, or any text.
24
+ */
25
+ export function syncPanelFill(panel) {
26
+ const filled = (panel.textContent ?? '').trim().length > 0 ||
27
+ Array.from(panel.querySelectorAll('*')).some((node) => node.tagName.includes('-') || node.matches(PANEL_CONTENT));
28
+ panel.toggleAttribute('data-empty', !filled);
29
+ syncPanelFit(panel, filled);
30
+ }
31
+ /**
32
+ * Lets the settings bar grow to the height its content needs.
33
+ *
34
+ * The bar is a fixed height so that moving between tools does not resize
35
+ * the stage under the user. When a tool needs more than that height, the
36
+ * overflow has nowhere to go: a wrapping flex container of fixed height has
37
+ * no scrollable cross-axis overflow, so `overflow: auto` never produces a
38
+ * scrollbar, and the sticky choice row — which pins itself inside the
39
+ * scrollport — is dragged up over the settings instead. The colour swatch
40
+ * ends up half covered and the fill toggle disappears behind the shapes.
41
+ *
42
+ * WebKit is where this surfaced, on a real iPhone: it lays these controls
43
+ * taller than Blink does, and at phone width crop, finetune and annotate
44
+ * needed 138, 140 and 136 pixels against the 112 the bar had. Raising the
45
+ * default would have taken those pixels off every stage in every engine, so
46
+ * the height is measured instead and only the bar that needs more gets it.
47
+ * `34cqh` still caps it, so a busy tool cannot eat the stage.
48
+ */
49
+ function syncPanelFit(panel, filled) {
50
+ panel.style.removeProperty('--sealpixel-panel-fit');
51
+ if (!filled)
52
+ return;
53
+ // Read after the reset, so a bar that has since shrunk measures its own
54
+ // content and not the height it was given last time.
55
+ const needed = panel.scrollHeight;
56
+ if (needed > panel.clientHeight) {
57
+ panel.style.setProperty('--sealpixel-panel-fit', `${needed}px`);
58
+ }
59
+ }
60
+ //# sourceMappingURL=panel-fit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-fit.js","sourceRoot":"","sources":["../../../src/components/editor/panel-fit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,aAAa,GAAG,8DAA8D,CAAC;AAErF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC9C,MAAM,MAAM,GACV,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAC3C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAC1C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CACpE,CAAC;IACJ,KAAK,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,CAAC;IAC7C,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,YAAY,CAAC,KAAkB,EAAE,MAAe;IACvD,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,wEAAwE;IACxE,qDAAqD;IACrD,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;IAClC,IAAI,MAAM,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC;QAChC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,uBAAuB,EAAE,GAAG,MAAM,IAAI,CAAC,CAAC;IAClE,CAAC;AACH,CAAC","sourcesContent":["/**\n * What makes a settings bar worth its height: a control, or anything that\n * draws. Plain `div`s are the tools' own scaffolding and never count.\n */\nconst PANEL_CONTENT = 'select, input, textarea, button, img, svg, canvas, a, [role]';\n\n/**\n * Collapses the settings bar when the open tool has nothing to put in it.\n *\n * A tool renders its own structure, and a structure can hold nothing: crop\n * with `rotation`, `flip` and `reset` off and a single enforced aspect emits\n * two empty wrappers. The bar is a fixed height on purpose — see `.panel` —\n * so that reserved an empty bordered surface and took the same height off\n * the stage. On the landing page's avatar card that was 240 px of nothing\n * against a 178 px stage, and the photo rendered at 10 percent.\n *\n * Read from the DOM rather than asked of the tool: every tool would\n * otherwise have to declare it, and a tool whose panel empties out only\n * under some options would get it wrong.\n *\n * Not measured by size either. The empty wrappers still lay out — the row\n * is 8px from its own gap and the group 4px from its border — so a\n * bounding box tells content and scaffolding apart not at all. What counts\n * is a control or a word: a custom element, a form control, or any text.\n */\nexport function syncPanelFill(panel: HTMLElement): void {\n const filled =\n (panel.textContent ?? '').trim().length > 0 ||\n Array.from(panel.querySelectorAll('*')).some(\n (node) => node.tagName.includes('-') || node.matches(PANEL_CONTENT),\n );\n panel.toggleAttribute('data-empty', !filled);\n syncPanelFit(panel, filled);\n}\n\n/**\n * Lets the settings bar grow to the height its content needs.\n *\n * The bar is a fixed height so that moving between tools does not resize\n * the stage under the user. When a tool needs more than that height, the\n * overflow has nowhere to go: a wrapping flex container of fixed height has\n * no scrollable cross-axis overflow, so `overflow: auto` never produces a\n * scrollbar, and the sticky choice row — which pins itself inside the\n * scrollport — is dragged up over the settings instead. The colour swatch\n * ends up half covered and the fill toggle disappears behind the shapes.\n *\n * WebKit is where this surfaced, on a real iPhone: it lays these controls\n * taller than Blink does, and at phone width crop, finetune and annotate\n * needed 138, 140 and 136 pixels against the 112 the bar had. Raising the\n * default would have taken those pixels off every stage in every engine, so\n * the height is measured instead and only the bar that needs more gets it.\n * `34cqh` still caps it, so a busy tool cannot eat the stage.\n */\nfunction syncPanelFit(panel: HTMLElement, filled: boolean): void {\n panel.style.removeProperty('--sealpixel-panel-fit');\n if (!filled) return;\n // Read after the reset, so a bar that has since shrunk measures its own\n // content and not the height it was given last time.\n const needed = panel.scrollHeight;\n if (needed > panel.clientHeight) {\n panel.style.setProperty('--sealpixel-panel-fit', `${needed}px`);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ /** The styles of `<sealpixel-editor>`: the shell grid, the settings bar, the toast and the empty state. */
2
+ export declare const editorStyles: import("lit").CSSResult;