@widgetic/editor 4.1.14 → 4.1.15
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/components/PreviewChromeControls.svelte +15 -21
- package/dist/components/WidgetPreview.svelte +136 -105
- package/dist/components/color-select/ColorSelect.svelte +203 -224
- package/dist/components/color-select/constants.d.ts +4 -2
- package/dist/components/color-select/constants.js +4 -2
- package/dist/components/color-select/render.js +10 -9
- package/dist/components/editors/CompositionEditorApp.svelte +47 -40
- package/dist/components/editors/EditLeaseNotice.svelte +44 -33
- package/dist/components/editors/EmbedEditor.svelte +133 -259
- package/dist/components/editors/PropsEditor.svelte +418 -1338
- package/dist/components/editors/props-editor.css +5 -68
- package/dist/components/ic/AngleInputController.svelte +202 -277
- package/dist/components/ic/BrowserInputController.svelte +813 -803
- package/dist/components/ic/CheckboxInputController.svelte +92 -169
- package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
- package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
- package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
- package/dist/components/ic/DateFieldInputController.svelte +455 -465
- package/dist/components/ic/DatePickerInputController.svelte +355 -368
- package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
- package/dist/components/ic/DropdownInputController.svelte +130 -200
- package/dist/components/ic/FixedPositionInputController.svelte +255 -276
- package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
- package/dist/components/ic/FontInputController.svelte +2110 -2231
- package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
- package/dist/components/ic/InputControllerHeader.svelte +141 -147
- package/dist/components/ic/InputControllerRow.svelte +74 -0
- package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +84 -47
- package/dist/components/ic/KnowledgeTextForm.svelte +35 -33
- package/dist/components/ic/NumberControls.svelte +303 -269
- package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
- package/dist/components/ic/NumberInputController.svelte +361 -301
- package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
- package/dist/components/ic/PositionInputController.svelte +253 -176
- package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
- package/dist/components/ic/RadioGroupInputController.svelte +71 -137
- package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
- package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
- package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
- package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
- package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
- package/dist/components/ic/SliderInputController.svelte +263 -332
- package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
- package/dist/components/ic/SliderRangeInputController.svelte +140 -144
- package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
- package/dist/components/ic/SwitchInputController.svelte +47 -109
- package/dist/components/ic/TagsInputController.svelte +95 -110
- package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
- package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
- package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
- package/dist/components/ic/TextInputController.svelte +65 -75
- package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
- package/dist/components/ic/TimeInputController.svelte +433 -431
- package/dist/components/ic/VectorInputController.svelte +1833 -1831
- package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
- package/dist/components/ic/index.d.ts +1 -0
- package/dist/components/ic/index.js +1 -0
- package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
- package/dist/components/ic/shared/ItemGrid.svelte +145 -179
- package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
- package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
- package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
- package/dist/i18n/language.d.ts +43 -36
- package/dist/i18n/messages.d.ts +41 -34
- package/dist/i18n/messages.js +47 -34
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +26 -2
- package/package.json +4 -4
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* TagsInputController
|
|
3
|
+
*
|
|
4
|
+
* A component for adding and removing tags, similar to email tag inputs.
|
|
1
5
|
<!--
|
|
2
6
|
* TagsInputController
|
|
3
7
|
*
|
|
@@ -12,143 +16,124 @@
|
|
|
12
16
|
-->
|
|
13
17
|
|
|
14
18
|
<script module lang="ts">
|
|
15
|
-
|
|
19
|
+
import type { InputControllerConfig } from './index';
|
|
16
20
|
|
|
17
21
|
/** Declared props contract — export lets below are annotated from it so the
|
|
18
22
|
* interface cannot drift from what the component actually reads. */
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
export interface TagsInputControllerProps {
|
|
24
|
+
label: string;
|
|
25
|
+
value?: string[];
|
|
26
|
+
onChange: (newValue: string[]) => void;
|
|
27
|
+
config?: InputControllerConfig;
|
|
28
|
+
helpText?: string;
|
|
29
|
+
onFocus?: () => void;
|
|
30
|
+
}
|
|
27
31
|
</script>
|
|
28
32
|
|
|
29
33
|
<script lang="ts">
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
import InputControllerRow from './InputControllerRow.svelte';
|
|
35
|
+
import { Tag } from '@widgetic/design-system/components';
|
|
36
|
+
import { useEditorLanguage } from '../../i18n/language';
|
|
37
|
+
import {
|
|
38
|
+
dirForUserText,
|
|
39
|
+
useTextDirection
|
|
40
|
+
} from '@widgetic/design-system/components/textDirection';
|
|
35
41
|
|
|
36
42
|
// The words of the editor in the language of the page.
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
const { t } = useEditorLanguage();
|
|
39
44
|
// The way the screen is read: a tag is what a person typed, so on a right to left screen it is read by its own first letter.
|
|
40
|
-
|
|
45
|
+
const textDirection = useTextDirection();
|
|
41
46
|
|
|
42
47
|
// Required props
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
export let label: TagsInputControllerProps['label'];
|
|
49
|
+
export let value: TagsInputControllerProps['value'] = [];
|
|
50
|
+
export let onChange: TagsInputControllerProps['onChange'];
|
|
51
|
+
export let config: TagsInputControllerProps['config'] = {};
|
|
52
|
+
export let helpText: TagsInputControllerProps['helpText'] = undefined;
|
|
53
|
+
export let onFocus: TagsInputControllerProps['onFocus'] = () => {};
|
|
54
|
+
|
|
50
55
|
// Optional: Class prop for external styling
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
let className = '';
|
|
57
|
+
export { className as class };
|
|
53
58
|
|
|
54
59
|
// Use config values with fallbacks
|
|
55
60
|
// The hint in the box: the one the widget gave, or the editor's own word in the language of the page.
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
$: placeholder = config.placeholder || $t('editor.tags.add');
|
|
62
|
+
|
|
58
63
|
// Component state
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
let inputElement: HTMLInputElement;
|
|
65
|
+
let tagInputContainer: HTMLDivElement;
|
|
61
66
|
// What is typed in the box right now. An empty box has no first letter to be read by, and reads left to right by itself
|
|
62
67
|
// even on a right to left screen: so it takes the direction of the screen until something is typed (see fieldDirection.ts).
|
|
63
|
-
|
|
68
|
+
let typedTag = '';
|
|
69
|
+
|
|
70
|
+
function handleTagRemove(tagToRemove: string) {
|
|
71
|
+
onChange(value.filter((tag) => tag !== tagToRemove));
|
|
72
|
+
}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
function handleInputKeydown(e: KeyboardEvent) {
|
|
75
|
+
if (e.key === ',' || e.key === 'Enter') {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
const input = e.target as HTMLInputElement;
|
|
78
|
+
const tagValue = input.value.trim();
|
|
69
79
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// Check if tag already exists to prevent duplicates
|
|
78
|
-
if (!value.includes(tagValue)) {
|
|
79
|
-
const newTags = [...value, tagValue];
|
|
80
|
-
onChange(newTags);
|
|
81
|
-
}
|
|
82
|
-
input.value = '';
|
|
83
|
-
typedTag = '';
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
80
|
+
if (tagValue && !value.includes(tagValue)) {
|
|
81
|
+
onChange([...value, tagValue]);
|
|
82
|
+
}
|
|
83
|
+
input.value = '';
|
|
84
|
+
typedTag = '';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
function handleContainerClick(e: MouseEvent) {
|
|
89
89
|
// If the click is not on the input itself, focus the input
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
const target = e.target as HTMLElement;
|
|
91
|
+
if (inputElement && target !== inputElement) {
|
|
92
|
+
inputElement.focus();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
95
|
</script>
|
|
96
96
|
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</div>
|
|
102
|
-
|
|
103
|
-
<div class="w-[185px]">
|
|
97
|
+
<InputControllerRow {label} {helpText} class={className}>
|
|
98
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
99
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
100
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
104
101
|
<!-- Tag container styled to match TextInputController -->
|
|
105
102
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
106
103
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
<span class="tag uppercase truncate max-w-[115px]" dir={dirForUserText($textDirection)}>{tag}</span>
|
|
137
|
-
<IconX class="w-4 h-4 text-white flex-shrink-0" />
|
|
138
|
-
</div>
|
|
139
|
-
{/each}
|
|
140
|
-
</div>
|
|
141
|
-
{/if}
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
104
|
+
<div
|
|
105
|
+
bind:this={tagInputContainer}
|
|
106
|
+
class="tags-container flex min-h-9 w-full flex-wrap items-center gap-1 rounded-lg bg-accent px-2 py-1.5 transition-colors duration-fast hover:bg-accent-hover focus-within:outline-hidden focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background"
|
|
107
|
+
on:click={handleContainerClick}
|
|
108
|
+
on:focusin={onFocus}
|
|
109
|
+
>
|
|
110
|
+
{#each value as tag}
|
|
111
|
+
<span dir={dirForUserText($textDirection)}>
|
|
112
|
+
<Tag
|
|
113
|
+
label={tag}
|
|
114
|
+
showRemove={true}
|
|
115
|
+
removeLabel={$t('editor.tags.remove')}
|
|
116
|
+
onRemove={() => handleTagRemove(tag)}
|
|
117
|
+
class="max-w-full"
|
|
118
|
+
/>
|
|
119
|
+
</span>
|
|
120
|
+
{/each}
|
|
121
|
+
<input
|
|
122
|
+
bind:this={inputElement}
|
|
123
|
+
type="text"
|
|
124
|
+
autocomplete="off"
|
|
125
|
+
dir={typedTag ? dirForUserText($textDirection) : undefined}
|
|
126
|
+
class="min-w-[4rem] flex-1 border-none bg-transparent text-body text-foreground outline-none placeholder:text-muted-foreground"
|
|
127
|
+
{placeholder}
|
|
128
|
+
on:input={(event) => (typedTag = event.currentTarget.value)}
|
|
129
|
+
on:keydown={handleInputKeydown}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
</InputControllerRow>
|
|
146
133
|
|
|
147
134
|
<style>
|
|
148
135
|
/* Allow container to expand vertically */
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
</style>
|
|
136
|
+
.tags-container {
|
|
137
|
+
box-sizing: border-box;
|
|
138
|
+
}
|
|
139
|
+
</style>
|