@widgetic/editor 4.0.7 → 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 +32 -1
- package/dist/components/WidgetPreview.svelte.d.ts +5 -0
- package/dist/components/editors/PropsEditor.svelte +171 -87
- package/dist/components/editors/PropsEditor.svelte.d.ts +3 -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 -19
- package/dist/components/ic/ColorPickerInputController.svelte.d.ts +42 -17
- 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 +39 -14
- 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 +28 -10
- package/dist/components/ic/FontInputController.svelte.d.ts +33 -18
- 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 +24 -10
- package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +26 -16
- 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 +18 -12
- 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/index.d.ts +1 -0
- package/dist/schemaViews.d.ts +105 -0
- package/dist/schemaViews.js +11 -0
- package/dist/utils/FontManager.js +1 -1
- package/package.json +9 -6
|
@@ -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,30 +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
|
|
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
|
|
72
100
|
|
|
73
101
|
// Use config values with fallbacks
|
|
74
|
-
export let saveRecentColors = true;
|
|
75
|
-
export let showOpacityControls = true;
|
|
76
|
-
export let autofocus:
|
|
77
|
-
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';
|
|
78
106
|
|
|
79
107
|
// Sizing props for easy adjustment (can be overridden by parent)
|
|
80
|
-
export let pickerSize = 200; // width/height of color area
|
|
81
|
-
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
|
|
82
110
|
$: swatchGap = 4;
|
|
83
111
|
$: swatchCount = 5;
|
|
84
112
|
$: swatchAreaWidth = pickerSize + sliderWidth + 14;
|
|
85
113
|
$: swatchSize = Math.floor((swatchAreaWidth - (swatchCount - 1) * swatchGap) / swatchCount);
|
|
86
114
|
|
|
87
115
|
// Exported opacity with default handling
|
|
88
|
-
export let opacity = config.defaultTransparency !== undefined ? config.defaultTransparency / 100 : 1;
|
|
116
|
+
export let opacity: ColorPickerInputControllerProps['opacity'] = config.defaultTransparency !== undefined ? config.defaultTransparency / 100 : 1;
|
|
89
117
|
|
|
90
118
|
// Tracks the last known opacity to maintain consistency
|
|
91
119
|
let lastKnownOpacity = opacity;
|
|
@@ -147,7 +175,7 @@
|
|
|
147
175
|
const opacityLineColor = "rgba(255, 255, 255, 0)";
|
|
148
176
|
|
|
149
177
|
// Add to props section
|
|
150
|
-
export let showRing = true;
|
|
178
|
+
export let showRing: ColorPickerInputControllerProps['showRing'] = true;
|
|
151
179
|
|
|
152
180
|
/**
|
|
153
181
|
* Generates RGBA border string based on color and opacity
|
|
@@ -1096,7 +1124,7 @@
|
|
|
1096
1124
|
}
|
|
1097
1125
|
|
|
1098
1126
|
// Exported onFocus handler with default no-op
|
|
1099
|
-
export let onFocus:
|
|
1127
|
+
export let onFocus: ColorPickerInputControllerProps['onFocus'] = () => {};
|
|
1100
1128
|
|
|
1101
1129
|
// Sets autofocus on mount if enabled
|
|
1102
1130
|
onMount(() => {
|
|
@@ -1119,7 +1147,7 @@
|
|
|
1119
1147
|
// Popover visibility is now handled by {#if open} conditional rendering
|
|
1120
1148
|
|
|
1121
1149
|
// Exported opacity change handler with default no-op
|
|
1122
|
-
export let onOpacityChange:
|
|
1150
|
+
export let onOpacityChange: ColorPickerInputControllerProps['onOpacityChange'] = () => {};
|
|
1123
1151
|
|
|
1124
1152
|
// Add these variables to track input position
|
|
1125
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,24 +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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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"];
|
|
35
58
|
focus?: () => void;
|
|
36
|
-
onOpacityChange?:
|
|
59
|
+
onOpacityChange?: ColorPickerInputControllerProps["onOpacityChange"];
|
|
37
60
|
}, {
|
|
38
61
|
focus: CustomEvent<any>;
|
|
39
62
|
blur: CustomEvent<any>;
|
|
@@ -42,6 +65,8 @@ declare const ColorPickerInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
|
42
65
|
} & {
|
|
43
66
|
[evt: string]: CustomEvent<any>;
|
|
44
67
|
}, {}, {
|
|
68
|
+
openDropdowns: any;
|
|
69
|
+
toggleDropdown: (id: string) => void;
|
|
45
70
|
focus: () => void;
|
|
46
71
|
}, string>;
|
|
47
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>;
|
|
@@ -17,6 +17,23 @@
|
|
|
17
17
|
* - Maintains dropdown state consistency
|
|
18
18
|
-->
|
|
19
19
|
|
|
20
|
+
<script module lang="ts">
|
|
21
|
+
import type { Writable } from 'svelte/store';
|
|
22
|
+
|
|
23
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
24
|
+
* interface cannot drift from what the component actually reads. */
|
|
25
|
+
export interface DatePickerInputControllerProps {
|
|
26
|
+
label: string;
|
|
27
|
+
value?: any;
|
|
28
|
+
onChange: (newValue: CalendarDate) => void;
|
|
29
|
+
description?: string;
|
|
30
|
+
controllerId: string;
|
|
31
|
+
openDropdowns: Writable<Set<string>>;
|
|
32
|
+
toggleDropdown: (id: string) => void;
|
|
33
|
+
onFocus?: () => void;
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
20
37
|
<script lang="ts">
|
|
21
38
|
// Svelte imports
|
|
22
39
|
import { onMount, onDestroy } from 'svelte';
|
|
@@ -35,14 +52,14 @@
|
|
|
35
52
|
import { IconCalendar } from '@widgetic/design-system/icons';
|
|
36
53
|
|
|
37
54
|
// Component props with TypeScript types
|
|
38
|
-
export let label:
|
|
39
|
-
export let value:
|
|
40
|
-
export let onChange:
|
|
41
|
-
export let description:
|
|
42
|
-
export let controllerId:
|
|
43
|
-
export let openDropdowns:
|
|
44
|
-
export let toggleDropdown:
|
|
45
|
-
export let onFocus:
|
|
55
|
+
export let label: DatePickerInputControllerProps['label'];
|
|
56
|
+
export let value: DatePickerInputControllerProps['value'];
|
|
57
|
+
export let onChange: DatePickerInputControllerProps['onChange'];
|
|
58
|
+
export let description: DatePickerInputControllerProps['description'] = undefined;
|
|
59
|
+
export let controllerId: DatePickerInputControllerProps['controllerId'];
|
|
60
|
+
export let openDropdowns: DatePickerInputControllerProps['openDropdowns'];
|
|
61
|
+
export let toggleDropdown: DatePickerInputControllerProps['toggleDropdown'];
|
|
62
|
+
export let onFocus: DatePickerInputControllerProps['onFocus'] = () => {};
|
|
46
63
|
|
|
47
64
|
// Default to today's date in local timezone for placeholder
|
|
48
65
|
let placeholder = today(getLocalTimeZone());
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import type { Writable } from 'svelte/store';
|
|
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 DatePickerInputControllerProps {
|
|
5
|
+
label: string;
|
|
6
|
+
value?: any;
|
|
7
|
+
onChange: (newValue: CalendarDate) => void;
|
|
8
|
+
description?: string;
|
|
9
|
+
controllerId: string;
|
|
10
|
+
openDropdowns: Writable<Set<string>>;
|
|
11
|
+
toggleDropdown: (id: string) => void;
|
|
12
|
+
onFocus?: () => void;
|
|
13
|
+
}
|
|
1
14
|
import { CalendarDate } from "@internationalized/date";
|
|
2
15
|
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
16
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
@@ -13,14 +26,14 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
13
26
|
z_$$bindings?: Bindings;
|
|
14
27
|
}
|
|
15
28
|
declare const DatePickerInputController: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
-
label:
|
|
17
|
-
value:
|
|
18
|
-
onChange:
|
|
19
|
-
description?:
|
|
20
|
-
controllerId:
|
|
21
|
-
openDropdowns:
|
|
22
|
-
toggleDropdown:
|
|
23
|
-
onFocus?:
|
|
29
|
+
label: DatePickerInputControllerProps["label"];
|
|
30
|
+
value: DatePickerInputControllerProps["value"];
|
|
31
|
+
onChange: DatePickerInputControllerProps["onChange"];
|
|
32
|
+
description?: DatePickerInputControllerProps["description"];
|
|
33
|
+
controllerId: DatePickerInputControllerProps["controllerId"];
|
|
34
|
+
openDropdowns: DatePickerInputControllerProps["openDropdowns"];
|
|
35
|
+
toggleDropdown: DatePickerInputControllerProps["toggleDropdown"];
|
|
36
|
+
onFocus?: DatePickerInputControllerProps["onFocus"];
|
|
24
37
|
}, {
|
|
25
38
|
[evt: string]: CustomEvent<any>;
|
|
26
39
|
}, {}, {}, string>;
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Writable } from 'svelte/store';
|
|
3
|
+
import type { InputControllerConfig } from './index';
|
|
4
|
+
|
|
5
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
6
|
+
* interface cannot drift from what the component actually reads. */
|
|
7
|
+
export interface DropdownInputControllerProps {
|
|
8
|
+
label: string;
|
|
9
|
+
defaultSelectedLabel?: string;
|
|
10
|
+
value: string | { value: string; label: string };
|
|
11
|
+
onChange: (newValue: string) => void;
|
|
12
|
+
config?: InputControllerConfig;
|
|
13
|
+
options?: { value: string; label: string }[];
|
|
14
|
+
description?: string;
|
|
15
|
+
controllerId: string;
|
|
16
|
+
openDropdowns: Writable<Set<string>>;
|
|
17
|
+
toggleDropdown: (id: string) => void;
|
|
18
|
+
onFocus?: () => void;
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
1
22
|
<script lang="ts">
|
|
2
23
|
/**
|
|
3
24
|
* DropdownInputController Component
|
|
@@ -10,7 +31,6 @@
|
|
|
10
31
|
* Required for component setup and cleanup
|
|
11
32
|
*/
|
|
12
33
|
import { onMount, onDestroy } from 'svelte';
|
|
13
|
-
import type { InputControllerConfig } from './index';
|
|
14
34
|
|
|
15
35
|
// Local Components imports
|
|
16
36
|
import { InputControllerHeader } from './index';
|
|
@@ -28,22 +48,22 @@
|
|
|
28
48
|
* Component Props
|
|
29
49
|
* External properties that configure the dropdown's behavior and appearance
|
|
30
50
|
*/
|
|
31
|
-
export let label:
|
|
32
|
-
export let defaultSelectedLabel:
|
|
33
|
-
export let value:
|
|
34
|
-
export let onChange:
|
|
35
|
-
export let config:
|
|
51
|
+
export let label: DropdownInputControllerProps['label'];
|
|
52
|
+
export let defaultSelectedLabel: DropdownInputControllerProps['defaultSelectedLabel'] = "Select an option";
|
|
53
|
+
export let value: DropdownInputControllerProps['value'];
|
|
54
|
+
export let onChange: DropdownInputControllerProps['onChange'];
|
|
55
|
+
export let config: DropdownInputControllerProps['config'] = {};
|
|
36
56
|
|
|
37
57
|
/**
|
|
38
58
|
* Configuration Options
|
|
39
59
|
* Derived from config prop with fallbacks
|
|
40
60
|
*/
|
|
41
|
-
export let options:
|
|
42
|
-
export let description:
|
|
43
|
-
export let controllerId:
|
|
44
|
-
export let openDropdowns:
|
|
45
|
-
export let toggleDropdown:
|
|
46
|
-
export let onFocus:
|
|
61
|
+
export let options: DropdownInputControllerProps['options'] = config.options || [];
|
|
62
|
+
export let description: DropdownInputControllerProps['description'] = undefined;
|
|
63
|
+
export let controllerId: DropdownInputControllerProps['controllerId'];
|
|
64
|
+
export let openDropdowns: DropdownInputControllerProps['openDropdowns'];
|
|
65
|
+
export let toggleDropdown: DropdownInputControllerProps['toggleDropdown'];
|
|
66
|
+
export let onFocus: DropdownInputControllerProps['onFocus'] = () => {};
|
|
47
67
|
|
|
48
68
|
/**
|
|
49
69
|
* Reactive State
|
|
@@ -124,8 +144,13 @@
|
|
|
124
144
|
}
|
|
125
145
|
}
|
|
126
146
|
|
|
127
|
-
|
|
128
|
-
|
|
147
|
+
/**
|
|
148
|
+
* The option label for the current selection. `value` accepts a bare string
|
|
149
|
+
* or an option object; normalize once instead of re-narrowing at each read.
|
|
150
|
+
*/
|
|
151
|
+
$: selectedValue = typeof value === 'string' ? value : value?.value;
|
|
152
|
+
$: triggerContent =
|
|
153
|
+
options.find((o) => o.value === selectedValue)?.label ?? defaultSelectedLabel;
|
|
129
154
|
</script>
|
|
130
155
|
|
|
131
156
|
<!-- Dropdown Container -->
|