@pixerate/editor-svelte 0.128.5 → 0.129.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.
- package/dist/image-editor/AdjustmentLayersPanel.svelte +3 -14
- package/dist/image-editor/BrushOptionsBar.svelte +4 -15
- package/dist/image-editor/ImageEditor.svelte +2 -5
- package/dist/image-editor/LayerEffectsPanel.svelte +2 -1
- package/dist/image-editor/ShapeOptionsBar.svelte +4 -17
- package/dist/image-editor/TypeOptionsBar.svelte +3 -2
- package/dist/image-editor/controls/ImageColor.svelte +21 -0
- package/dist/image-editor/controls/ImageColor.svelte.d.ts +4 -0
- package/dist/image-editor/controls/ImageParameterColor.svelte +9 -0
- package/dist/image-editor/controls/ImageParameterColor.svelte.d.ts +4 -0
- package/dist/image-editor/controls/controls.d.ts +17 -0
- package/dist/image-editor/controls/parameterControls.d.ts +1 -1
- package/dist/image-editor/controls/parameterControls.js +3 -1
- package/dist/image-editor/index.d.ts +2 -1
- package/dist/image-editor/index.js +1 -0
- package/dist/parameters/ParameterColor.svelte +59 -51
- package/dist/parameters/ParameterColor.svelte.d.ts +2 -0
- package/dist/parameters/ParameterFieldControl.svelte +1 -1
- package/dist/parameters/controls.d.ts +20 -0
- package/dist/parameters/controls.js +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import ImageColor from './controls/ImageColor.svelte';
|
|
2
3
|
import ImageCheckbox from './controls/ImageCheckbox.svelte';
|
|
3
4
|
import ImageSelect from './controls/ImageSelect.svelte';
|
|
4
5
|
import { imageSectionTitleClass } from './styles.js';
|
|
@@ -242,13 +243,7 @@
|
|
|
242
243
|
{:else if layer.kind === 'photoFilter'}
|
|
243
244
|
<label class="flex items-center gap-2 text-foreground">
|
|
244
245
|
Filter colour
|
|
245
|
-
<
|
|
246
|
-
type="color"
|
|
247
|
-
aria-label="Filter colour"
|
|
248
|
-
value={layer.params.color}
|
|
249
|
-
oninput={(e) => setParam(layer, 'color', (e.target as HTMLInputElement).value)}
|
|
250
|
-
class="h-5 w-8 bg-transparent"
|
|
251
|
-
/>
|
|
246
|
+
<ImageColor label="Filter colour" value={layer.params.color} oninput={(v) => setParam(layer, 'color', v)} />
|
|
252
247
|
</label>
|
|
253
248
|
{:else if layer.kind === 'invert'}
|
|
254
249
|
<p class="text-muted-foreground text-[11px]">Invert has no settings.</p>
|
|
@@ -275,13 +270,7 @@
|
|
|
275
270
|
<ImageCheckbox label="Tint" checked={layer.params.tint !== null} onchange={(on) => setParam(layer, 'tint', on ? '#e1d3b3' : null)} />
|
|
276
271
|
Tint
|
|
277
272
|
{#if layer.params.tint}
|
|
278
|
-
<
|
|
279
|
-
type="color"
|
|
280
|
-
aria-label="Tint colour"
|
|
281
|
-
value={layer.params.tint}
|
|
282
|
-
oninput={(e) => setParam(layer, 'tint', (e.target as HTMLInputElement).value)}
|
|
283
|
-
class="h-5 w-8 bg-transparent"
|
|
284
|
-
/>
|
|
273
|
+
<ImageColor label="Tint colour" value={layer.params.tint} oninput={(v) => setParam(layer, 'tint', v)} />
|
|
285
274
|
{/if}
|
|
286
275
|
</label>
|
|
287
276
|
{/if}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import ImageColor from './controls/ImageColor.svelte';
|
|
2
3
|
import ImageCheckbox from './controls/ImageCheckbox.svelte';
|
|
3
|
-
import { imageChipClass
|
|
4
|
+
import { imageChipClass } from './styles.js';
|
|
4
5
|
import type { ImageEditorController } from '@pixerate/editor/image-editor';
|
|
5
6
|
import {
|
|
6
7
|
userErrorMessage,
|
|
@@ -70,23 +71,11 @@
|
|
|
70
71
|
|
|
71
72
|
<div class="flex items-center gap-2" role="group" aria-label="Colours">
|
|
72
73
|
<label class="flex items-center gap-1">
|
|
73
|
-
<
|
|
74
|
-
type="color"
|
|
75
|
-
aria-label="Foreground colour"
|
|
76
|
-
value={view.foreground}
|
|
77
|
-
oninput={(e) => controller.setPaintOptions({ foreground: (e.target as HTMLInputElement).value })}
|
|
78
|
-
class={imageColorInputClass}
|
|
79
|
-
/>
|
|
74
|
+
<ImageColor label="Foreground colour" value={view.foreground} oninput={(foreground) => controller.setPaintOptions({ foreground })} />
|
|
80
75
|
<span class="text-muted-foreground">FG</span>
|
|
81
76
|
</label>
|
|
82
77
|
<label class="flex items-center gap-1">
|
|
83
|
-
<
|
|
84
|
-
type="color"
|
|
85
|
-
aria-label="Background colour"
|
|
86
|
-
value={view.background}
|
|
87
|
-
oninput={(e) => controller.setPaintOptions({ background: (e.target as HTMLInputElement).value })}
|
|
88
|
-
class={imageColorInputClass}
|
|
89
|
-
/>
|
|
78
|
+
<ImageColor label="Background colour" value={view.background} oninput={(background) => controller.setPaintOptions({ background })} />
|
|
90
79
|
<span class="text-muted-foreground">BG</span>
|
|
91
80
|
</label>
|
|
92
81
|
<button type="button" title="Swap colours (X)" class={imageChipClass(false)} onclick={() => controller.swapPaintColors()}>Swap</button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import ImageColor from './controls/ImageColor.svelte';
|
|
2
3
|
import { imageDividerClass, imageEditorFrameClass, imageEditorHeaderClass, imageErrorBannerClass, imageHeaderButtonClass, imagePrimaryButtonClass, imageRangeClass, imageSectionClass, imageSectionTitleClass, imageSelectClass, imageSidebarClass, imageSmallButtonClass, imageSpinnerClass, imageTabClass, imageTabListClass } from './styles.js';
|
|
3
4
|
import type {
|
|
4
5
|
ExportOptions,
|
|
@@ -747,11 +748,7 @@
|
|
|
747
748
|
<!-- Color & Size -->
|
|
748
749
|
<div class="flex items-center gap-2 mt-2">
|
|
749
750
|
<span class="text-muted-foreground">Color:</span>
|
|
750
|
-
<
|
|
751
|
-
type="color"
|
|
752
|
-
bind:value={activeColor}
|
|
753
|
-
class="w-8 h-8 rounded border border-border cursor-pointer bg-transparent"
|
|
754
|
-
/>
|
|
751
|
+
<ImageColor label="Annotation colour" value={activeColor} oninput={(c) => (activeColor = c)} />
|
|
755
752
|
<div class="flex-1 ml-2">
|
|
756
753
|
<div class="flex justify-between text-muted-foreground mb-0.5">
|
|
757
754
|
<span>Width:</span>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import ImageColor from './controls/ImageColor.svelte';
|
|
2
3
|
import ImageCheckbox from './controls/ImageCheckbox.svelte';
|
|
3
4
|
import ImageRange from './controls/ImageRange.svelte';
|
|
4
5
|
import ImageSelect from './controls/ImageSelect.svelte';
|
|
@@ -155,7 +156,7 @@
|
|
|
155
156
|
</label>
|
|
156
157
|
{:else if c.type === 'color'}
|
|
157
158
|
<label class="flex items-center gap-1.5 text-foreground">
|
|
158
|
-
<
|
|
159
|
+
<ImageColor label={c.label} value={c.value} disabled={view.model.readOnly} oninput={(v) => change(row.id, c, v)} />
|
|
159
160
|
{c.label}
|
|
160
161
|
</label>
|
|
161
162
|
{:else if c.type === 'checkbox'}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import ImageColor from './controls/ImageColor.svelte';
|
|
2
3
|
import ImageCheckbox from './controls/ImageCheckbox.svelte';
|
|
3
4
|
import ImageRange from './controls/ImageRange.svelte';
|
|
4
|
-
import { imageChipClass,
|
|
5
|
+
import { imageChipClass, imageFieldClass } from './styles.js';
|
|
5
6
|
import type { ImageEditorController, ShapeToolOptions } from '@pixerate/editor/image-editor';
|
|
6
7
|
import { LIVE_SHAPE_KINDS, SHAPE_KIND_LABELS, applyShapeOptions } from '@pixerate/editor/image-editor';
|
|
7
8
|
import { untrack } from 'svelte';
|
|
@@ -58,26 +59,12 @@
|
|
|
58
59
|
<label class="flex items-center gap-1">
|
|
59
60
|
<ImageCheckbox label="Fill" checked={options.fill !== null} onchange={(on) => set({ fill: on ? '#4f46e5' : null })} />
|
|
60
61
|
Fill
|
|
61
|
-
<
|
|
62
|
-
type="color"
|
|
63
|
-
aria-label="Fill colour"
|
|
64
|
-
disabled={options.fill === null}
|
|
65
|
-
value={options.fill ?? '#4f46e5'}
|
|
66
|
-
oninput={(e) => set({ fill: value(e) })}
|
|
67
|
-
class={imageColorInputClass}
|
|
68
|
-
/>
|
|
62
|
+
<ImageColor label="Fill colour" disabled={options.fill === null} value={options.fill ?? '#4f46e5'} oninput={(fill) => set({ fill })} />
|
|
69
63
|
</label>
|
|
70
64
|
<label class="flex items-center gap-1">
|
|
71
65
|
<ImageCheckbox label="Stroke" checked={options.stroke !== null} onchange={(on) => set({ stroke: on ? '#000000' : null })} />
|
|
72
66
|
Stroke
|
|
73
|
-
<
|
|
74
|
-
type="color"
|
|
75
|
-
aria-label="Stroke colour"
|
|
76
|
-
disabled={options.stroke === null}
|
|
77
|
-
value={options.stroke ?? '#000000'}
|
|
78
|
-
oninput={(e) => set({ stroke: value(e) })}
|
|
79
|
-
class={imageColorInputClass}
|
|
80
|
-
/>
|
|
67
|
+
<ImageColor label="Stroke colour" disabled={options.stroke === null} value={options.stroke ?? '#000000'} oninput={(stroke) => set({ stroke })} />
|
|
81
68
|
</label>
|
|
82
69
|
<label class="flex items-center gap-1">
|
|
83
70
|
Width
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import ImageColor from './controls/ImageColor.svelte';
|
|
3
|
+
import { imageChipClass } from './styles.js';
|
|
3
4
|
import type { ImageEditorController, TextAlign, TextEditSession, TextStyle, TypeToolOptions } from '@pixerate/editor/image-editor';
|
|
4
5
|
import { TEXT_ALIGNS } from '@pixerate/editor/image-editor';
|
|
5
6
|
import { untrack } from 'svelte';
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
</label>
|
|
101
102
|
<button type="button" aria-pressed={view.shown.fontWeight >= 600} class="{imageChipClass(view.shown.fontWeight >= 600)} font-bold" onclick={() => style({ fontWeight: view.shown.fontWeight >= 600 ? 400 : 700 })}>B</button>
|
|
102
103
|
<button type="button" aria-pressed={view.shown.italic} class="{imageChipClass(view.shown.italic)} italic" onclick={() => style({ italic: !view.shown.italic })}>I</button>
|
|
103
|
-
<
|
|
104
|
+
<ImageColor label="Text colour" value={view.shown.color} oninput={(color) => style({ color })} />
|
|
104
105
|
</div>
|
|
105
106
|
<div class="flex gap-1" role="toolbar" aria-label="Alignment">
|
|
106
107
|
{#each TEXT_ALIGNS as a (a)}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getImageEditorControls, type ImageColorProps } from './controls.js';
|
|
3
|
+
import { imageColorInputClass } from '../styles.js';
|
|
4
|
+
|
|
5
|
+
let { value, label, alpha = false, disabled = false, oninput, onstart, onend, class: className = '' }: ImageColorProps = $props();
|
|
6
|
+
const Host = getImageEditorControls().Color;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#if Host}
|
|
10
|
+
<Host {value} {label} {alpha} {disabled} {oninput} {onstart} {onend} class={className} />
|
|
11
|
+
{:else}
|
|
12
|
+
<!-- The native well has no alpha: keep the stored alpha on what it picks. -->
|
|
13
|
+
<input
|
|
14
|
+
type="color"
|
|
15
|
+
aria-label={label}
|
|
16
|
+
value={value.slice(0, 7)}
|
|
17
|
+
{disabled}
|
|
18
|
+
oninput={(e) => oninput((e.currentTarget as HTMLInputElement).value + (alpha ? value.slice(7, 9) : ''))}
|
|
19
|
+
class="{imageColorInputClass} {className}"
|
|
20
|
+
/>
|
|
21
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ParameterColorProps } from '../../parameters/controls.js';
|
|
3
|
+
import ImageColor from './ImageColor.svelte';
|
|
4
|
+
|
|
5
|
+
let { value, label, alpha = false, disabled = false, class: className = '', onchange, ongesturestart, ongestureend }: ParameterColorProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<!-- A parameter colour drawn with the host's image-editor `Color`. -->
|
|
9
|
+
<ImageColor {value} {label} {alpha} {disabled} class={className} oninput={onchange} onstart={ongesturestart} onend={ongestureend} />
|
|
@@ -42,6 +42,22 @@ export interface ImageSelectProps {
|
|
|
42
42
|
onchange: (value: string) => void;
|
|
43
43
|
class?: string;
|
|
44
44
|
}
|
|
45
|
+
/** A colour well in the image editor's panels. */
|
|
46
|
+
export interface ImageColorProps {
|
|
47
|
+
/** `#rrggbb`, or `#rrggbbaa` with `alpha`. */
|
|
48
|
+
value: string;
|
|
49
|
+
/** The accessible name. */
|
|
50
|
+
label: string;
|
|
51
|
+
/** Whether the colour has an alpha channel. */
|
|
52
|
+
alpha?: boolean;
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
/** Every change while the colour is picked. */
|
|
55
|
+
oninput: (value: string) => void;
|
|
56
|
+
/** A pick (e.g. a drag in the picker) starts: changes until `onend` merge into one undo step. */
|
|
57
|
+
onstart?: () => void;
|
|
58
|
+
onend?: () => void;
|
|
59
|
+
class?: string;
|
|
60
|
+
}
|
|
45
61
|
/**
|
|
46
62
|
* The host's own form controls for the image editor's panels. Any left out fall back to the
|
|
47
63
|
* editor's plain inputs.
|
|
@@ -50,6 +66,7 @@ export interface ImageEditorControls {
|
|
|
50
66
|
Checkbox?: Component<ImageCheckboxProps>;
|
|
51
67
|
Range?: Component<ImageRangeProps>;
|
|
52
68
|
Select?: Component<ImageSelectProps>;
|
|
69
|
+
Color?: Component<ImageColorProps>;
|
|
53
70
|
}
|
|
54
71
|
/**
|
|
55
72
|
* Makes the image editor's panels below this component use the host's controls (call it while
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ParameterComponents } from '../../parameters/controls.js';
|
|
2
2
|
import type { ImageEditorControls } from './controls.js';
|
|
3
|
-
/** The host's image-editor `Range` and `
|
|
3
|
+
/** The host's image-editor `Range`, `Select` and `Color` as parameter controls (only the ones it set). */
|
|
4
4
|
export declare function imageEditorParameterComponents(controls: ImageEditorControls): ParameterComponents;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import ImageParameterColor from './ImageParameterColor.svelte';
|
|
1
2
|
import ImageParameterSelect from './ImageParameterSelect.svelte';
|
|
2
3
|
import ImageParameterSlider from './ImageParameterSlider.svelte';
|
|
3
|
-
/** The host's image-editor `Range` and `
|
|
4
|
+
/** The host's image-editor `Range`, `Select` and `Color` as parameter controls (only the ones it set). */
|
|
4
5
|
export function imageEditorParameterComponents(controls) {
|
|
5
6
|
return {
|
|
6
7
|
slider: controls.Range ? ImageParameterSlider : undefined,
|
|
7
8
|
select: controls.Select ? ImageParameterSelect : undefined,
|
|
9
|
+
color: controls.Color ? ImageParameterColor : undefined,
|
|
8
10
|
};
|
|
9
11
|
}
|
|
@@ -43,7 +43,8 @@ export * from './imageEditorState.svelte.js';
|
|
|
43
43
|
export { default as ImageCheckbox } from './controls/ImageCheckbox.svelte';
|
|
44
44
|
export { default as ImageRange } from './controls/ImageRange.svelte';
|
|
45
45
|
export { default as ImageSelect } from './controls/ImageSelect.svelte';
|
|
46
|
-
export {
|
|
46
|
+
export { default as ImageColor } from './controls/ImageColor.svelte';
|
|
47
|
+
export { setImageEditorControls, getImageEditorControls, type ImageEditorControls, type ImageCheckboxProps, type ImageRangeProps, type ImageSelectProps, type ImageSelectOption, type ImageColorProps, } from './controls/controls.js';
|
|
47
48
|
export type ImageEditorProps = ComponentProps<typeof ImageEditorComponent>;
|
|
48
49
|
export type ImageEditorCanvasProps = ComponentProps<typeof ImageEditorCanvasComponent>;
|
|
49
50
|
export type CanvasSizePanelProps = ComponentProps<typeof CanvasSizePanelComponent>;
|
|
@@ -22,5 +22,6 @@ export * from './imageEditorState.svelte.js';
|
|
|
22
22
|
export { default as ImageCheckbox } from './controls/ImageCheckbox.svelte';
|
|
23
23
|
export { default as ImageRange } from './controls/ImageRange.svelte';
|
|
24
24
|
export { default as ImageSelect } from './controls/ImageSelect.svelte';
|
|
25
|
+
export { default as ImageColor } from './controls/ImageColor.svelte';
|
|
25
26
|
export { setImageEditorControls, getImageEditorControls, } from './controls/controls.js';
|
|
26
27
|
export { applyRegionMosaic, applyRegionBlur, resolveMosaicRegionBounds } from '@pixerate/editor/image-editor';
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import ColorPicker from '../color/ColorPicker.svelte';
|
|
4
4
|
import ParameterCommitInput from './ParameterCommitInput.svelte';
|
|
5
5
|
import { parameterInputClass } from './styles.js';
|
|
6
|
+
import { getParameterComponents, resolveParameterComponents, type ParameterComponents } from './controls.js';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
field: ColorParameterField;
|
|
@@ -13,9 +14,10 @@
|
|
|
13
14
|
ongestureend?: () => void;
|
|
14
15
|
disabled?: boolean;
|
|
15
16
|
id?: string;
|
|
17
|
+
components?: ParameterComponents;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
let { field, value, onchange, ongesturestart, ongestureend, disabled = false, id }: Props = $props();
|
|
20
|
+
let { field, value, onchange, ongesturestart, ongestureend, disabled = false, id, components }: Props = $props();
|
|
19
21
|
|
|
20
22
|
const alpha = $derived(!!field.alpha);
|
|
21
23
|
const hex = $derived(normalizeHexColor(value, true) ?? '#000000ff');
|
|
@@ -23,6 +25,8 @@
|
|
|
23
25
|
const shown = $derived(alpha ? hex : rgb);
|
|
24
26
|
const off = $derived(disabled || !!field.readOnly);
|
|
25
27
|
const name = $derived(parameterLabel(field));
|
|
28
|
+
const context = getParameterComponents();
|
|
29
|
+
const CustomColor = $derived(resolveParameterComponents(components, context).color);
|
|
26
30
|
|
|
27
31
|
let open = $state(false);
|
|
28
32
|
let containerEl = $state<HTMLDivElement | null>(null);
|
|
@@ -52,57 +56,61 @@
|
|
|
52
56
|
});
|
|
53
57
|
</script>
|
|
54
58
|
|
|
55
|
-
<!-- A colour picker with a hex box and a popup ColorPicker. -->
|
|
56
|
-
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
class="{parameterInputClass} font-mono"
|
|
77
|
-
oncommit={(text) => {
|
|
78
|
-
const next = normalizeHexColor(text, alpha);
|
|
79
|
-
if (next) onchange(next);
|
|
80
|
-
}}
|
|
81
|
-
/>
|
|
82
|
-
</div>
|
|
83
|
-
{#if open}
|
|
84
|
-
<div
|
|
85
|
-
bind:this={popoverEl}
|
|
86
|
-
role="dialog"
|
|
87
|
-
aria-label={name}
|
|
88
|
-
tabindex="-1"
|
|
89
|
-
onfocusout={(e) => {
|
|
90
|
-
if (popoverEl && !popoverEl.contains(e.relatedTarget as Node)) {
|
|
91
|
-
open = false;
|
|
92
|
-
}
|
|
93
|
-
}}
|
|
94
|
-
class="absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl"
|
|
95
|
-
style="background: var(--popover, var(--background, #fff));"
|
|
96
|
-
>
|
|
97
|
-
<ColorPicker
|
|
59
|
+
<!-- A colour picker with a hex box and a popup ColorPicker, or the host's own colour control. -->
|
|
60
|
+
{#if CustomColor}
|
|
61
|
+
<CustomColor {id} value={shown} {alpha} swatches={field.swatches} disabled={off} label={name} {onchange} {ongesturestart} {ongestureend} />
|
|
62
|
+
{:else}
|
|
63
|
+
<div bind:this={containerEl} class="relative space-y-1.5">
|
|
64
|
+
<div class="flex items-center gap-2">
|
|
65
|
+
<button
|
|
66
|
+
bind:this={buttonEl}
|
|
67
|
+
type="button"
|
|
68
|
+
aria-label={name}
|
|
69
|
+
aria-expanded={open}
|
|
70
|
+
aria-haspopup="dialog"
|
|
71
|
+
disabled={off}
|
|
72
|
+
onclick={() => (open = !open)}
|
|
73
|
+
class="relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
|
|
74
|
+
>
|
|
75
|
+
<span class="absolute inset-0" style:background={shown}></span>
|
|
76
|
+
</button>
|
|
77
|
+
<ParameterCommitInput
|
|
78
|
+
{id}
|
|
79
|
+
aria-label="{name} hex"
|
|
98
80
|
value={shown}
|
|
99
|
-
{alpha}
|
|
100
|
-
swatches={field.swatches}
|
|
101
81
|
disabled={off}
|
|
102
|
-
{
|
|
103
|
-
{
|
|
104
|
-
{
|
|
82
|
+
spellcheck={false}
|
|
83
|
+
class="{parameterInputClass} font-mono"
|
|
84
|
+
oncommit={(text) => {
|
|
85
|
+
const next = normalizeHexColor(text, alpha);
|
|
86
|
+
if (next) onchange(next);
|
|
87
|
+
}}
|
|
105
88
|
/>
|
|
106
89
|
</div>
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
{#if open}
|
|
91
|
+
<div
|
|
92
|
+
bind:this={popoverEl}
|
|
93
|
+
role="dialog"
|
|
94
|
+
aria-label={name}
|
|
95
|
+
tabindex="-1"
|
|
96
|
+
onfocusout={(e) => {
|
|
97
|
+
if (popoverEl && !popoverEl.contains(e.relatedTarget as Node)) {
|
|
98
|
+
open = false;
|
|
99
|
+
}
|
|
100
|
+
}}
|
|
101
|
+
class="absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl"
|
|
102
|
+
style="background: var(--popover, var(--background, #fff));"
|
|
103
|
+
>
|
|
104
|
+
<ColorPicker
|
|
105
|
+
value={shown}
|
|
106
|
+
{alpha}
|
|
107
|
+
swatches={field.swatches}
|
|
108
|
+
disabled={off}
|
|
109
|
+
{onchange}
|
|
110
|
+
{ongesturestart}
|
|
111
|
+
{ongestureend}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
{/if}
|
|
115
|
+
</div>
|
|
116
|
+
{/if}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ColorParameterField } from '@pixerate/editor/parameters';
|
|
2
|
+
import { type ParameterComponents } from './controls.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
field: ColorParameterField;
|
|
4
5
|
value: string;
|
|
@@ -8,6 +9,7 @@ interface Props {
|
|
|
8
9
|
ongestureend?: () => void;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
id?: string;
|
|
12
|
+
components?: ParameterComponents;
|
|
11
13
|
}
|
|
12
14
|
declare const ParameterColor: import("svelte").Component<Props, {}, "">;
|
|
13
15
|
type ParameterColor = ReturnType<typeof ParameterColor>;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
{:else if field.type === 'choice'}
|
|
34
34
|
<ParameterSelect {field} value={value as string | number} onchange={set} {disabled} {id} {components} />
|
|
35
35
|
{:else if field.type === 'color'}
|
|
36
|
-
<ParameterColor {field} value={value as string} onchange={set} {ongesturestart} {ongestureend} {disabled} {id} />
|
|
36
|
+
<ParameterColor {field} value={value as string} onchange={set} {ongesturestart} {ongestureend} {disabled} {id} {components} />
|
|
37
37
|
{:else if field.type === 'vector'}
|
|
38
38
|
<ParameterVector {field} value={value as number[]} onchange={set} {disabled} {id} {components} />
|
|
39
39
|
{:else if field.type === 'image'}
|
|
@@ -55,11 +55,31 @@ export interface ParameterSelectProps {
|
|
|
55
55
|
style?: string;
|
|
56
56
|
onchange: (value: string | number) => void;
|
|
57
57
|
}
|
|
58
|
+
/** Props for a custom colour control in parameter panels. */
|
|
59
|
+
export interface ParameterColorProps {
|
|
60
|
+
id?: string;
|
|
61
|
+
/** `#rrggbb`, or `#rrggbbaa` with `alpha`. */
|
|
62
|
+
value: string;
|
|
63
|
+
/** Whether the field has an alpha channel. */
|
|
64
|
+
alpha?: boolean;
|
|
65
|
+
/** Suggested colours for the field, if it has any. */
|
|
66
|
+
swatches?: readonly string[];
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/** The field's label. */
|
|
69
|
+
label: string;
|
|
70
|
+
class?: string;
|
|
71
|
+
style?: string;
|
|
72
|
+
onchange: (value: string) => void;
|
|
73
|
+
/** A pick starts: changes until `ongestureend` merge into one undo step. */
|
|
74
|
+
ongesturestart?: () => void;
|
|
75
|
+
ongestureend?: () => void;
|
|
76
|
+
}
|
|
58
77
|
/** Host form controls for parameter panels. Any left out fall back to the default controls. */
|
|
59
78
|
export interface ParameterComponents {
|
|
60
79
|
input?: Component<ParameterInputProps>;
|
|
61
80
|
slider?: Component<ParameterSliderProps>;
|
|
62
81
|
select?: Component<ParameterSelectProps>;
|
|
82
|
+
color?: Component<ParameterColorProps>;
|
|
63
83
|
}
|
|
64
84
|
/** Makes the parameter panels below this component use the host's controls (call it while a component initialises). */
|
|
65
85
|
export declare function setParameterComponents(components: ParameterComponents): ParameterComponents;
|
|
@@ -14,5 +14,6 @@ export function resolveParameterComponents(explicit, fallback = getParameterComp
|
|
|
14
14
|
input: explicit?.input ?? fallback.input,
|
|
15
15
|
slider: explicit?.slider ?? fallback.slider,
|
|
16
16
|
select: explicit?.select ?? fallback.select,
|
|
17
|
+
color: explicit?.color ?? fallback.color,
|
|
17
18
|
};
|
|
18
19
|
}
|