@widgetic/editor 4.0.6 → 4.0.8
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/README.md +12 -1
- package/dist/components/WidgetPreview.svelte +42 -1
- package/dist/components/WidgetPreview.svelte.d.ts +8 -0
- package/dist/components/editors/EmbedEditor.svelte +101 -530
- package/dist/components/editors/EmbedEditor.svelte.d.ts +7 -17
- package/dist/components/editors/PropsEditor.svelte +328 -142
- package/dist/components/editors/PropsEditor.svelte.d.ts +13 -2
- package/dist/components/ic/AngleInputController.svelte +21 -7
- package/dist/components/ic/AngleInputController.svelte.d.ts +16 -6
- package/dist/components/ic/BrowserInputController.svelte +28 -15
- package/dist/components/ic/BrowserInputController.svelte.d.ts +25 -19
- package/dist/components/ic/CheckboxInputController.svelte +21 -7
- package/dist/components/ic/CheckboxInputController.svelte.d.ts +25 -15
- package/dist/components/ic/ColorPickerInputController.svelte +47 -21
- package/dist/components/ic/ColorPickerInputController.svelte.d.ts +42 -19
- package/dist/components/ic/DateFieldInputController.svelte +21 -7
- package/dist/components/ic/DateFieldInputController.svelte.d.ts +24 -14
- package/dist/components/ic/DatePickerInputController.svelte +25 -8
- package/dist/components/ic/DatePickerInputController.svelte.d.ts +21 -8
- package/dist/components/ic/DropdownInputController.svelte +69 -19
- package/dist/components/ic/DropdownInputController.svelte.d.ts +33 -17
- package/dist/components/ic/FixedPositionInputController.svelte +24 -10
- package/dist/components/ic/FixedPositionInputController.svelte.d.ts +16 -4
- package/dist/components/ic/FontInputController.svelte +53 -18
- package/dist/components/ic/FontInputController.svelte.d.ts +33 -18
- package/dist/components/ic/InputControllerRenderer.svelte +98 -0
- package/dist/components/ic/InputControllerRenderer.svelte.d.ts +40 -0
- package/dist/components/ic/NumberInputController.svelte +23 -9
- package/dist/components/ic/NumberInputController.svelte.d.ts +18 -7
- package/dist/components/ic/PositionInputController.svelte +17 -5
- package/dist/components/ic/PositionInputController.svelte.d.ts +20 -11
- package/dist/components/ic/RadioGroupInputController.svelte +21 -7
- package/dist/components/ic/RadioGroupInputController.svelte.d.ts +22 -12
- package/dist/components/ic/RangeCalendarInputController.svelte +34 -16
- package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +25 -11
- package/dist/components/ic/RoundedCornersInputController.svelte +26 -22
- package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +26 -18
- package/dist/components/ic/SliderInputController.svelte +41 -18
- package/dist/components/ic/SliderInputController.svelte.d.ts +35 -19
- package/dist/components/ic/SliderRangeInputController.svelte +27 -11
- package/dist/components/ic/SliderRangeInputController.svelte.d.ts +22 -9
- package/dist/components/ic/SwitchInputController.svelte +17 -5
- package/dist/components/ic/SwitchInputController.svelte.d.ts +14 -5
- package/dist/components/ic/TagsInputController.svelte +21 -7
- package/dist/components/ic/TagsInputController.svelte.d.ts +16 -6
- package/dist/components/ic/TextAreaInputController.svelte +44 -25
- package/dist/components/ic/TextAreaInputController.svelte.d.ts +6 -4
- package/dist/components/ic/TextAreaPreviewInputController.svelte +21 -7
- package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +16 -6
- package/dist/components/ic/TextInputController.svelte +23 -8
- package/dist/components/ic/TextInputController.svelte.d.ts +20 -8
- package/dist/components/ic/TimeInputController.svelte +17 -5
- package/dist/components/ic/TimeInputController.svelte.d.ts +14 -5
- package/dist/components/ic/VectorInputController.svelte +29 -10
- package/dist/components/ic/VectorInputController.svelte.d.ts +33 -18
- package/dist/components/icons/locked.svelte +5 -1
- package/dist/components/icons/locked.svelte.d.ts +11 -24
- package/dist/components/icons/unlocked.svelte +5 -1
- package/dist/components/icons/unlocked.svelte.d.ts +11 -24
- package/dist/index.d.ts +1 -0
- package/dist/schemaViews.d.ts +105 -0
- package/dist/schemaViews.js +11 -0
- package/dist/utils/FontManager.js +11 -4
- package/package.json +16 -12
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ContentSchemaView, DesignSchemaView } from '../../schemaViews.js';
|
|
1
2
|
/**
|
|
2
3
|
* STYLES from Widgetic Design System
|
|
3
4
|
* Note: props-editor.css global rules (body, *) moved to app.css (standalone only).
|
|
@@ -24,8 +25,8 @@ declare const PropsEditor: $$__sveltets_2_IsomorphicComponent<{
|
|
|
24
25
|
style?: string;
|
|
25
26
|
width?: string;
|
|
26
27
|
height?: string;
|
|
27
|
-
designSchema?:
|
|
28
|
-
contentSchema?:
|
|
28
|
+
designSchema?: DesignSchemaView | null;
|
|
29
|
+
contentSchema?: ContentSchemaView | undefined;
|
|
29
30
|
itemTemplate?: any;
|
|
30
31
|
designTabTitle?: string;
|
|
31
32
|
contentTabTitle?: string;
|
|
@@ -33,6 +34,15 @@ declare const PropsEditor: $$__sveltets_2_IsomorphicComponent<{
|
|
|
33
34
|
defaultOpen?: boolean;
|
|
34
35
|
showDragHandle?: boolean;
|
|
35
36
|
enableDrag?: boolean;
|
|
37
|
+
/** Show Save status control in the top drag/header bar (composition page). */ showSaveButton?: boolean;
|
|
38
|
+
/** True when local edits are not yet persisted. */ saveDirty?: boolean;
|
|
39
|
+
/** True while a save request is in flight. */ saveSaving?: boolean;
|
|
40
|
+
/** Optional content below the shared toolbar, before property fields. */ headerContent?: any;
|
|
41
|
+
headerClass?: string;
|
|
42
|
+
dragHandleClass?: string;
|
|
43
|
+
title?: string;
|
|
44
|
+
/** Hide the default missing-schema message for header-only editors. */ showSchemaError?: boolean;
|
|
45
|
+
/** Optional layout wrapper moved by this editor's built-in drag and position API. */ positionTarget?: any;
|
|
36
46
|
initialDesignValues?: Record<string, any>;
|
|
37
47
|
initialContentValues?: Record<string, any>;
|
|
38
48
|
updateDesignValue?: (propertyId: string, value: any) => void;
|
|
@@ -42,6 +52,7 @@ declare const PropsEditor: $$__sveltets_2_IsomorphicComponent<{
|
|
|
42
52
|
top: number;
|
|
43
53
|
};
|
|
44
54
|
}, {
|
|
55
|
+
save: CustomEvent<any>;
|
|
45
56
|
updated: CustomEvent<any>;
|
|
46
57
|
propertyChange: CustomEvent<any>;
|
|
47
58
|
goToItem: CustomEvent<any>;
|
|
@@ -11,19 +11,33 @@
|
|
|
11
11
|
* - Smooth transitions and visual feedback
|
|
12
12
|
-->
|
|
13
13
|
|
|
14
|
+
<script module lang="ts">
|
|
15
|
+
import type { InputControllerConfig } from './index';
|
|
16
|
+
|
|
17
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
18
|
+
* interface cannot drift from what the component actually reads. */
|
|
19
|
+
export interface AngleInputControllerProps {
|
|
20
|
+
label: string;
|
|
21
|
+
value?: number;
|
|
22
|
+
onChange: (newValue: number) => void;
|
|
23
|
+
config?: InputControllerConfig;
|
|
24
|
+
helpText?: string;
|
|
25
|
+
onFocus?: () => void;
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
14
29
|
<script lang="ts">
|
|
15
30
|
import { onMount, onDestroy } from 'svelte';
|
|
16
31
|
import { Button, Input } from '@widgetic/design-system/components';
|
|
17
32
|
import InputControllerHeader from './InputControllerHeader.svelte';
|
|
18
33
|
import NumberControls from './NumberControls.svelte';
|
|
19
|
-
import type { InputControllerConfig } from './index';
|
|
20
34
|
|
|
21
|
-
export let label:
|
|
22
|
-
export let value:
|
|
23
|
-
export let onChange:
|
|
24
|
-
export let config:
|
|
25
|
-
export let helpText:
|
|
26
|
-
export let onFocus:
|
|
35
|
+
export let label: AngleInputControllerProps['label'];
|
|
36
|
+
export let value: AngleInputControllerProps['value'] = 0;
|
|
37
|
+
export let onChange: AngleInputControllerProps['onChange'];
|
|
38
|
+
export let config: AngleInputControllerProps['config'] = {};
|
|
39
|
+
export let helpText: AngleInputControllerProps['helpText'] = undefined;
|
|
40
|
+
export let onFocus: AngleInputControllerProps['onFocus'] = () => {};
|
|
27
41
|
|
|
28
42
|
// Circle indicator state
|
|
29
43
|
let isDragging = false;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { InputControllerConfig } from './index';
|
|
2
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
3
|
+
* interface cannot drift from what the component actually reads. */
|
|
4
|
+
export interface AngleInputControllerProps {
|
|
5
|
+
label: string;
|
|
6
|
+
value?: number;
|
|
7
|
+
onChange: (newValue: number) => void;
|
|
8
|
+
config?: InputControllerConfig;
|
|
9
|
+
helpText?: string;
|
|
10
|
+
onFocus?: () => void;
|
|
11
|
+
}
|
|
2
12
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
13
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
14
|
$$bindings?: Bindings;
|
|
@@ -13,12 +23,12 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
13
23
|
z_$$bindings?: Bindings;
|
|
14
24
|
}
|
|
15
25
|
declare const AngleInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
-
label:
|
|
17
|
-
value?:
|
|
18
|
-
onChange:
|
|
19
|
-
config?:
|
|
20
|
-
helpText?:
|
|
21
|
-
onFocus?:
|
|
26
|
+
label: AngleInputControllerProps["label"];
|
|
27
|
+
value?: AngleInputControllerProps["value"];
|
|
28
|
+
onChange: AngleInputControllerProps["onChange"];
|
|
29
|
+
config?: AngleInputControllerProps["config"];
|
|
30
|
+
helpText?: AngleInputControllerProps["helpText"];
|
|
31
|
+
onFocus?: AngleInputControllerProps["onFocus"];
|
|
22
32
|
}, {
|
|
23
33
|
[evt: string]: CustomEvent<any>;
|
|
24
34
|
}, {}, {}, string>;
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { InputControllerConfig } from './index';
|
|
3
|
+
|
|
4
|
+
interface FileValue {
|
|
5
|
+
id: string;
|
|
6
|
+
file: string;
|
|
7
|
+
url: string;
|
|
8
|
+
hash?: string; // Add hash property for ThumbHash
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
12
|
+
* interface cannot drift from what the component actually reads. */
|
|
13
|
+
export interface BrowserInputControllerProps {
|
|
14
|
+
header?: { label: string; helpText?: string };
|
|
15
|
+
label?: string;
|
|
16
|
+
value?: string | FileValue;
|
|
17
|
+
onChange?: (newValue: string | FileValue) => void;
|
|
18
|
+
portalTarget?: string | HTMLElement;
|
|
19
|
+
config?: InputControllerConfig;
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
1
23
|
<script lang="ts">
|
|
2
24
|
/**
|
|
3
25
|
* BrowserInputController Component
|
|
@@ -16,8 +38,6 @@
|
|
|
16
38
|
import X from '../icons/x.svelte';
|
|
17
39
|
// console.log("BrowserInputController - Tooltip:", Tooltip);
|
|
18
40
|
|
|
19
|
-
// config imports
|
|
20
|
-
import type { InputControllerConfig } from './index';
|
|
21
41
|
|
|
22
42
|
// utils imports
|
|
23
43
|
import MediaManager from '../../utils/MediaManager';
|
|
@@ -32,26 +52,19 @@
|
|
|
32
52
|
|
|
33
53
|
import { InputControllerHeader } from './index';
|
|
34
54
|
|
|
35
|
-
interface FileValue {
|
|
36
|
-
id: string;
|
|
37
|
-
file: string;
|
|
38
|
-
url: string;
|
|
39
|
-
hash?: string; // Add hash property for ThumbHash
|
|
40
|
-
}
|
|
41
|
-
|
|
42
55
|
// Component props with default values
|
|
43
|
-
export let header:
|
|
44
|
-
export let label:
|
|
45
|
-
export let value:
|
|
46
|
-
export let onChange:
|
|
47
|
-
export let portalTarget:
|
|
56
|
+
export let header: BrowserInputControllerProps['header'] = undefined;
|
|
57
|
+
export let label: BrowserInputControllerProps['label'] = '';
|
|
58
|
+
export let value: BrowserInputControllerProps['value'] = '';
|
|
59
|
+
export let onChange: BrowserInputControllerProps['onChange'] = () => {};
|
|
60
|
+
export let portalTarget: BrowserInputControllerProps['portalTarget'] = 'portal-element';
|
|
48
61
|
|
|
49
62
|
/** Full-panel overlay when portaled to props-editor panel (not document body). */
|
|
50
63
|
$: fillEditorPanel =
|
|
51
64
|
portalTarget === 'props-editor-file-browser-portal' ||
|
|
52
65
|
(portalTarget instanceof HTMLElement &&
|
|
53
66
|
portalTarget.id === 'props-editor-file-browser-portal');
|
|
54
|
-
export let config:
|
|
67
|
+
export let config: BrowserInputControllerProps['config'] = {};
|
|
55
68
|
|
|
56
69
|
// Extract allowed file types from config or default to all files
|
|
57
70
|
const fileTypes = config.fileTypes || ['*'];
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import type { InputControllerConfig } from './index';
|
|
2
|
+
interface FileValue {
|
|
3
|
+
id: string;
|
|
4
|
+
file: string;
|
|
5
|
+
url: string;
|
|
6
|
+
hash?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
9
|
+
* interface cannot drift from what the component actually reads. */
|
|
10
|
+
export interface BrowserInputControllerProps {
|
|
11
|
+
header?: {
|
|
12
|
+
label: string;
|
|
13
|
+
helpText?: string;
|
|
14
|
+
};
|
|
15
|
+
label?: string;
|
|
16
|
+
value?: string | FileValue;
|
|
17
|
+
onChange?: (newValue: string | FileValue) => void;
|
|
18
|
+
portalTarget?: string | HTMLElement;
|
|
19
|
+
config?: InputControllerConfig;
|
|
20
|
+
}
|
|
2
21
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
22
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
23
|
$$bindings?: Bindings;
|
|
@@ -13,25 +32,12 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
13
32
|
z_$$bindings?: Bindings;
|
|
14
33
|
}
|
|
15
34
|
declare const BrowserInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
-
header?:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
id: string;
|
|
23
|
-
file: string;
|
|
24
|
-
url: string;
|
|
25
|
-
hash?: string;
|
|
26
|
-
};
|
|
27
|
-
onChange?: (newValue: string | {
|
|
28
|
-
id: string;
|
|
29
|
-
file: string;
|
|
30
|
-
url: string;
|
|
31
|
-
hash?: string;
|
|
32
|
-
}) => void;
|
|
33
|
-
portalTarget?: string | HTMLElement;
|
|
34
|
-
config?: InputControllerConfig;
|
|
35
|
+
header?: BrowserInputControllerProps["header"];
|
|
36
|
+
label?: BrowserInputControllerProps["label"];
|
|
37
|
+
value?: BrowserInputControllerProps["value"];
|
|
38
|
+
onChange?: BrowserInputControllerProps["onChange"];
|
|
39
|
+
portalTarget?: BrowserInputControllerProps["portalTarget"];
|
|
40
|
+
config?: BrowserInputControllerProps["config"];
|
|
35
41
|
}, {
|
|
36
42
|
[evt: string]: CustomEvent<any>;
|
|
37
43
|
}, {}, {}, string>;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { InputControllerConfig } from './index';
|
|
3
|
+
|
|
4
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
5
|
+
* interface cannot drift from what the component actually reads. */
|
|
6
|
+
export interface CheckboxInputControllerProps {
|
|
7
|
+
value: string[] | { value: string; label: string }[] | string | { value: string; label: string };
|
|
8
|
+
onChange: (newValue: string[]) => void;
|
|
9
|
+
config?: InputControllerConfig;
|
|
10
|
+
description?: string;
|
|
11
|
+
onFocus?: () => void;
|
|
12
|
+
options?: { value: string; label: string }[];
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
1
16
|
<script lang="ts">
|
|
2
17
|
/**
|
|
3
18
|
* CheckboxInputController Component
|
|
@@ -10,7 +25,6 @@
|
|
|
10
25
|
* Required for component setup and cleanup
|
|
11
26
|
*/
|
|
12
27
|
import { onMount, onDestroy } from 'svelte';
|
|
13
|
-
import type { InputControllerConfig } from './index';
|
|
14
28
|
|
|
15
29
|
/**
|
|
16
30
|
* UI Components Imports
|
|
@@ -22,17 +36,17 @@
|
|
|
22
36
|
* Component Props
|
|
23
37
|
* External properties that configure the checkbox group's behavior and appearance
|
|
24
38
|
*/
|
|
25
|
-
export let value:
|
|
26
|
-
export let onChange:
|
|
27
|
-
export let config:
|
|
28
|
-
export let description:
|
|
29
|
-
export let onFocus:
|
|
39
|
+
export let value: CheckboxInputControllerProps['value']; // Selected value(s)
|
|
40
|
+
export let onChange: CheckboxInputControllerProps['onChange']; // Callback for value changes
|
|
41
|
+
export let config: CheckboxInputControllerProps['config'] = {}; // Additional configuration options
|
|
42
|
+
export let description: CheckboxInputControllerProps['description'] = undefined; // Optional help description text
|
|
43
|
+
export let onFocus: CheckboxInputControllerProps['onFocus'] = () => {}; // Focus event handler
|
|
30
44
|
|
|
31
45
|
/**
|
|
32
46
|
* Configuration Options
|
|
33
47
|
* Derived from config prop with fallbacks
|
|
34
48
|
*/
|
|
35
|
-
export let options:
|
|
49
|
+
export let options: CheckboxInputControllerProps['options'] = config.options || []; // Available options
|
|
36
50
|
|
|
37
51
|
/**
|
|
38
52
|
* Local state
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import type { InputControllerConfig } from './index';
|
|
2
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
3
|
+
* interface cannot drift from what the component actually reads. */
|
|
4
|
+
export interface CheckboxInputControllerProps {
|
|
5
|
+
value: string[] | {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}[] | string | {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
onChange: (newValue: string[]) => void;
|
|
13
|
+
config?: InputControllerConfig;
|
|
14
|
+
description?: string;
|
|
15
|
+
onFocus?: () => void;
|
|
16
|
+
options?: {
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
2
21
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
22
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
23
|
$$bindings?: Bindings;
|
|
@@ -16,24 +35,15 @@ declare const CheckboxInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
|
16
35
|
/**
|
|
17
36
|
* Component Props
|
|
18
37
|
* External properties that configure the checkbox group's behavior and appearance
|
|
19
|
-
*/ value:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
label: string;
|
|
25
|
-
};
|
|
26
|
-
onChange: (newValue: string[]) => void;
|
|
27
|
-
config?: InputControllerConfig;
|
|
28
|
-
description?: string | undefined;
|
|
29
|
-
onFocus?: () => void;
|
|
38
|
+
*/ value: CheckboxInputControllerProps["value"];
|
|
39
|
+
onChange: CheckboxInputControllerProps["onChange"];
|
|
40
|
+
config?: CheckboxInputControllerProps["config"];
|
|
41
|
+
description?: CheckboxInputControllerProps["description"];
|
|
42
|
+
onFocus?: CheckboxInputControllerProps["onFocus"];
|
|
30
43
|
/**
|
|
31
44
|
* Configuration Options
|
|
32
45
|
* Derived from config prop with fallbacks
|
|
33
|
-
*/ options?:
|
|
34
|
-
value: string;
|
|
35
|
-
label: string;
|
|
36
|
-
}[];
|
|
46
|
+
*/ options?: CheckboxInputControllerProps["options"];
|
|
37
47
|
}, {
|
|
38
48
|
[evt: string]: CustomEvent<any>;
|
|
39
49
|
}, {}, {}, string>;
|
|
@@ -18,14 +18,38 @@
|
|
|
18
18
|
* - Prevents recursive updates
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
<script module lang="ts">
|
|
22
|
+
import type { InputControllerConfig } from './index';
|
|
23
|
+
|
|
24
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
25
|
+
* interface cannot drift from what the component actually reads. */
|
|
26
|
+
export interface ColorPickerInputControllerProps {
|
|
27
|
+
label?: string;
|
|
28
|
+
value?: string;
|
|
29
|
+
onChange: (newValue: string) => void;
|
|
30
|
+
controllerId?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
config?: InputControllerConfig;
|
|
33
|
+
helpText?: string;
|
|
34
|
+
saveRecentColors?: boolean;
|
|
35
|
+
showOpacityControls?: boolean;
|
|
36
|
+
autofocus?: boolean;
|
|
37
|
+
portalTarget?: string | HTMLElement;
|
|
38
|
+
pickerSize?: number;
|
|
39
|
+
sliderWidth?: number;
|
|
40
|
+
opacity?: number;
|
|
41
|
+
showRing?: boolean;
|
|
42
|
+
onFocus?: () => void;
|
|
43
|
+
onOpacityChange?: (opacity: number) => void;
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
21
47
|
<script lang="ts">
|
|
22
48
|
// Svelte imports
|
|
23
49
|
import { onMount, onDestroy, tick } from 'svelte';
|
|
24
50
|
import { createEventDispatcher } from 'svelte';
|
|
25
51
|
const dispatch = createEventDispatcher();
|
|
26
52
|
|
|
27
|
-
// Config imports
|
|
28
|
-
import type { InputControllerConfig } from './index';
|
|
29
53
|
|
|
30
54
|
// Shadcn UI Components
|
|
31
55
|
import { Input } from '@widgetic/design-system/components';
|
|
@@ -62,32 +86,34 @@
|
|
|
62
86
|
* Component Props
|
|
63
87
|
* External properties that configure the color picker's behavior
|
|
64
88
|
*/
|
|
65
|
-
export let label:
|
|
66
|
-
export let value = '#000000'; // Current color value
|
|
67
|
-
export let onChange:
|
|
68
|
-
export let controllerId:
|
|
69
|
-
export let id:
|
|
70
|
-
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
89
|
+
export let label: ColorPickerInputControllerProps['label'] = ''; // Display label
|
|
90
|
+
export let value: ColorPickerInputControllerProps['value'] = '#000000'; // Current color value
|
|
91
|
+
export let onChange: ColorPickerInputControllerProps['onChange']; // Value change callback
|
|
92
|
+
export let controllerId: ColorPickerInputControllerProps['controllerId'] = '';
|
|
93
|
+
export let id: ColorPickerInputControllerProps['id'] = '';
|
|
94
|
+
// Passed through the dynamic-component props object but never read here —
|
|
95
|
+
// export const keeps the init-set contract without the unused-reactive warning.
|
|
96
|
+
export const openDropdowns: any = undefined;
|
|
97
|
+
export const toggleDropdown: (id: string) => void = () => {};
|
|
98
|
+
export let config: ColorPickerInputControllerProps['config'] = {}; // Additional configuration
|
|
99
|
+
export let helpText: ColorPickerInputControllerProps['helpText'] = undefined; // Help text for the input
|
|
74
100
|
|
|
75
101
|
// Use config values with fallbacks
|
|
76
|
-
export let saveRecentColors = true;
|
|
77
|
-
export let showOpacityControls = true;
|
|
78
|
-
export let autofocus:
|
|
79
|
-
export let portalTarget = 'editor-portal';
|
|
102
|
+
export let saveRecentColors: ColorPickerInputControllerProps['saveRecentColors'] = true;
|
|
103
|
+
export let showOpacityControls: ColorPickerInputControllerProps['showOpacityControls'] = true;
|
|
104
|
+
export let autofocus: ColorPickerInputControllerProps['autofocus'] = false;
|
|
105
|
+
export let portalTarget: ColorPickerInputControllerProps['portalTarget'] = 'editor-portal';
|
|
80
106
|
|
|
81
107
|
// Sizing props for easy adjustment (can be overridden by parent)
|
|
82
|
-
export let pickerSize = 200; // width/height of color area
|
|
83
|
-
export let sliderWidth = 24; // width of hue bar and opacity input
|
|
108
|
+
export let pickerSize: ColorPickerInputControllerProps['pickerSize'] = 200; // width/height of color area
|
|
109
|
+
export let sliderWidth: ColorPickerInputControllerProps['sliderWidth'] = 24; // width of hue bar and opacity input
|
|
84
110
|
$: swatchGap = 4;
|
|
85
111
|
$: swatchCount = 5;
|
|
86
112
|
$: swatchAreaWidth = pickerSize + sliderWidth + 14;
|
|
87
113
|
$: swatchSize = Math.floor((swatchAreaWidth - (swatchCount - 1) * swatchGap) / swatchCount);
|
|
88
114
|
|
|
89
115
|
// Exported opacity with default handling
|
|
90
|
-
export let opacity = config.defaultTransparency !== undefined ? config.defaultTransparency / 100 : 1;
|
|
116
|
+
export let opacity: ColorPickerInputControllerProps['opacity'] = config.defaultTransparency !== undefined ? config.defaultTransparency / 100 : 1;
|
|
91
117
|
|
|
92
118
|
// Tracks the last known opacity to maintain consistency
|
|
93
119
|
let lastKnownOpacity = opacity;
|
|
@@ -149,7 +175,7 @@
|
|
|
149
175
|
const opacityLineColor = "rgba(255, 255, 255, 0)";
|
|
150
176
|
|
|
151
177
|
// Add to props section
|
|
152
|
-
export let showRing = true;
|
|
178
|
+
export let showRing: ColorPickerInputControllerProps['showRing'] = true;
|
|
153
179
|
|
|
154
180
|
/**
|
|
155
181
|
* Generates RGBA border string based on color and opacity
|
|
@@ -1098,7 +1124,7 @@
|
|
|
1098
1124
|
}
|
|
1099
1125
|
|
|
1100
1126
|
// Exported onFocus handler with default no-op
|
|
1101
|
-
export let onFocus:
|
|
1127
|
+
export let onFocus: ColorPickerInputControllerProps['onFocus'] = () => {};
|
|
1102
1128
|
|
|
1103
1129
|
// Sets autofocus on mount if enabled
|
|
1104
1130
|
onMount(() => {
|
|
@@ -1121,7 +1147,7 @@
|
|
|
1121
1147
|
// Popover visibility is now handled by {#if open} conditional rendering
|
|
1122
1148
|
|
|
1123
1149
|
// Exported opacity change handler with default no-op
|
|
1124
|
-
export let onOpacityChange:
|
|
1150
|
+
export let onOpacityChange: ColorPickerInputControllerProps['onOpacityChange'] = () => {};
|
|
1125
1151
|
|
|
1126
1152
|
// Add these variables to track input position
|
|
1127
1153
|
let inputComponent: any;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import type { InputControllerConfig } from './index';
|
|
2
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
3
|
+
* interface cannot drift from what the component actually reads. */
|
|
4
|
+
export interface ColorPickerInputControllerProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
onChange: (newValue: string) => void;
|
|
8
|
+
controllerId?: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
config?: InputControllerConfig;
|
|
11
|
+
helpText?: string;
|
|
12
|
+
saveRecentColors?: boolean;
|
|
13
|
+
showOpacityControls?: boolean;
|
|
14
|
+
autofocus?: boolean;
|
|
15
|
+
portalTarget?: string | HTMLElement;
|
|
16
|
+
pickerSize?: number;
|
|
17
|
+
sliderWidth?: number;
|
|
18
|
+
opacity?: number;
|
|
19
|
+
showRing?: boolean;
|
|
20
|
+
onFocus?: () => void;
|
|
21
|
+
onOpacityChange?: (opacity: number) => void;
|
|
22
|
+
}
|
|
2
23
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
24
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
25
|
$$bindings?: Bindings;
|
|
@@ -16,26 +37,26 @@ declare const ColorPickerInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
|
16
37
|
/**
|
|
17
38
|
* Component Props
|
|
18
39
|
* External properties that configure the color picker's behavior
|
|
19
|
-
*/ label?:
|
|
20
|
-
value?:
|
|
21
|
-
onChange:
|
|
22
|
-
controllerId?:
|
|
23
|
-
id?:
|
|
24
|
-
openDropdowns
|
|
25
|
-
toggleDropdown
|
|
26
|
-
config?:
|
|
27
|
-
helpText?:
|
|
28
|
-
saveRecentColors?:
|
|
29
|
-
showOpacityControls?:
|
|
30
|
-
autofocus?:
|
|
31
|
-
portalTarget?:
|
|
32
|
-
pickerSize?:
|
|
33
|
-
sliderWidth?:
|
|
34
|
-
opacity?:
|
|
35
|
-
showRing?:
|
|
36
|
-
onFocus?:
|
|
40
|
+
*/ label?: ColorPickerInputControllerProps["label"];
|
|
41
|
+
value?: ColorPickerInputControllerProps["value"];
|
|
42
|
+
onChange: ColorPickerInputControllerProps["onChange"];
|
|
43
|
+
controllerId?: ColorPickerInputControllerProps["controllerId"];
|
|
44
|
+
id?: ColorPickerInputControllerProps["id"];
|
|
45
|
+
openDropdowns?: any;
|
|
46
|
+
toggleDropdown?: (id: string) => void;
|
|
47
|
+
config?: ColorPickerInputControllerProps["config"];
|
|
48
|
+
helpText?: ColorPickerInputControllerProps["helpText"];
|
|
49
|
+
saveRecentColors?: ColorPickerInputControllerProps["saveRecentColors"];
|
|
50
|
+
showOpacityControls?: ColorPickerInputControllerProps["showOpacityControls"];
|
|
51
|
+
autofocus?: ColorPickerInputControllerProps["autofocus"];
|
|
52
|
+
portalTarget?: ColorPickerInputControllerProps["portalTarget"];
|
|
53
|
+
pickerSize?: ColorPickerInputControllerProps["pickerSize"];
|
|
54
|
+
sliderWidth?: ColorPickerInputControllerProps["sliderWidth"];
|
|
55
|
+
opacity?: ColorPickerInputControllerProps["opacity"];
|
|
56
|
+
showRing?: ColorPickerInputControllerProps["showRing"];
|
|
57
|
+
onFocus?: ColorPickerInputControllerProps["onFocus"];
|
|
37
58
|
focus?: () => void;
|
|
38
|
-
onOpacityChange?:
|
|
59
|
+
onOpacityChange?: ColorPickerInputControllerProps["onOpacityChange"];
|
|
39
60
|
}, {
|
|
40
61
|
focus: CustomEvent<any>;
|
|
41
62
|
blur: CustomEvent<any>;
|
|
@@ -44,6 +65,8 @@ declare const ColorPickerInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
|
44
65
|
} & {
|
|
45
66
|
[evt: string]: CustomEvent<any>;
|
|
46
67
|
}, {}, {
|
|
68
|
+
openDropdowns: any;
|
|
69
|
+
toggleDropdown: (id: string) => void;
|
|
47
70
|
focus: () => void;
|
|
48
71
|
}, string>;
|
|
49
72
|
type ColorPickerInputController = InstanceType<typeof ColorPickerInputController>;
|
|
@@ -11,10 +11,24 @@
|
|
|
11
11
|
* - Visual feedback consistent with other input controllers
|
|
12
12
|
-->
|
|
13
13
|
|
|
14
|
+
<script module lang="ts">
|
|
15
|
+
import type { InputControllerConfig } from './index';
|
|
16
|
+
|
|
17
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
18
|
+
* interface cannot drift from what the component actually reads. */
|
|
19
|
+
export interface DateFieldInputControllerProps {
|
|
20
|
+
label: string;
|
|
21
|
+
value: { day: number; month: number; year: number };
|
|
22
|
+
onChange: (newValue: { day: number; month: number; year: number }) => void;
|
|
23
|
+
config?: InputControllerConfig;
|
|
24
|
+
helpText?: string;
|
|
25
|
+
onFocus?: () => void;
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
14
29
|
<script lang="ts">
|
|
15
30
|
import { onMount, tick } from 'svelte';
|
|
16
31
|
import InputControllerHeader from './InputControllerHeader.svelte';
|
|
17
|
-
import type { InputControllerConfig } from './index';
|
|
18
32
|
|
|
19
33
|
// Constants
|
|
20
34
|
const MIN_DAY = 1;
|
|
@@ -25,12 +39,12 @@
|
|
|
25
39
|
const MAX_YEAR = 2100;
|
|
26
40
|
|
|
27
41
|
// Required props
|
|
28
|
-
export let label:
|
|
29
|
-
export let value:
|
|
30
|
-
export let onChange:
|
|
31
|
-
export let config:
|
|
32
|
-
export let helpText:
|
|
33
|
-
export let onFocus:
|
|
42
|
+
export let label: DateFieldInputControllerProps['label'];
|
|
43
|
+
export let value: DateFieldInputControllerProps['value'];
|
|
44
|
+
export let onChange: DateFieldInputControllerProps['onChange'];
|
|
45
|
+
export let config: DateFieldInputControllerProps['config'] = {};
|
|
46
|
+
export let helpText: DateFieldInputControllerProps['helpText'] = undefined;
|
|
47
|
+
export let onFocus: DateFieldInputControllerProps['onFocus'] = () => {};
|
|
34
48
|
|
|
35
49
|
// Optional: Class prop for external styling
|
|
36
50
|
let className = '';
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import type { InputControllerConfig } from './index';
|
|
2
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
3
|
+
* interface cannot drift from what the component actually reads. */
|
|
4
|
+
export interface DateFieldInputControllerProps {
|
|
5
|
+
label: string;
|
|
6
|
+
value: {
|
|
7
|
+
day: number;
|
|
8
|
+
month: number;
|
|
9
|
+
year: number;
|
|
10
|
+
};
|
|
11
|
+
onChange: (newValue: {
|
|
12
|
+
day: number;
|
|
13
|
+
month: number;
|
|
14
|
+
year: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
config?: InputControllerConfig;
|
|
17
|
+
helpText?: string;
|
|
18
|
+
onFocus?: () => void;
|
|
19
|
+
}
|
|
2
20
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
21
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
22
|
$$bindings?: Bindings;
|
|
@@ -13,20 +31,12 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
13
31
|
z_$$bindings?: Bindings;
|
|
14
32
|
}
|
|
15
33
|
declare const DateFieldInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
-
label:
|
|
17
|
-
value:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
onChange: (newValue: {
|
|
23
|
-
day: number;
|
|
24
|
-
month: number;
|
|
25
|
-
year: number;
|
|
26
|
-
}) => void;
|
|
27
|
-
config?: InputControllerConfig;
|
|
28
|
-
helpText?: string | undefined;
|
|
29
|
-
onFocus?: () => void;
|
|
34
|
+
label: DateFieldInputControllerProps["label"];
|
|
35
|
+
value: DateFieldInputControllerProps["value"];
|
|
36
|
+
onChange: DateFieldInputControllerProps["onChange"];
|
|
37
|
+
config?: DateFieldInputControllerProps["config"];
|
|
38
|
+
helpText?: DateFieldInputControllerProps["helpText"];
|
|
39
|
+
onFocus?: DateFieldInputControllerProps["onFocus"];
|
|
30
40
|
class?: string;
|
|
31
41
|
}, {
|
|
32
42
|
[evt: string]: CustomEvent<any>;
|