polymorph-ui-components 0.1.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/README.md +354 -0
- package/dist/Accordion/Accordion.svelte +28 -0
- package/dist/Accordion/Accordion.svelte.d.ts +4 -0
- package/dist/Accordion/properties.d.ts +7 -0
- package/dist/Accordion/properties.js +1 -0
- package/dist/Animations/ModalAnimation.svelte +55 -0
- package/dist/Animations/ModalAnimation.svelte.d.ts +12 -0
- package/dist/Animations/OverlayAnimation.svelte +14 -0
- package/dist/Animations/OverlayAnimation.svelte.d.ts +7 -0
- package/dist/Avatar/Avatar.svelte +122 -0
- package/dist/Avatar/Avatar.svelte.d.ts +4 -0
- package/dist/Avatar/properties.d.ts +15 -0
- package/dist/Avatar/properties.js +1 -0
- package/dist/Badge/Badge.svelte +53 -0
- package/dist/Badge/Badge.svelte.d.ts +4 -0
- package/dist/Badge/properties.d.ts +6 -0
- package/dist/Badge/properties.js +1 -0
- package/dist/Banner/Banner.svelte +158 -0
- package/dist/Banner/Banner.svelte.d.ts +4 -0
- package/dist/Banner/properties.d.ts +19 -0
- package/dist/Banner/properties.js +1 -0
- package/dist/Book/Book.svelte +281 -0
- package/dist/Book/Book.svelte.d.ts +4 -0
- package/dist/Book/properties.d.ts +24 -0
- package/dist/Book/properties.js +1 -0
- package/dist/Browser/Browser.svelte +176 -0
- package/dist/Browser/Browser.svelte.d.ts +3 -0
- package/dist/Browser/properties.d.ts +14 -0
- package/dist/Browser/properties.js +1 -0
- package/dist/Button/Button.svelte +153 -0
- package/dist/Button/Button.svelte.d.ts +4 -0
- package/dist/Button/properties.d.ts +24 -0
- package/dist/Button/properties.js +1 -0
- package/dist/Calendar/Calendar.svelte +477 -0
- package/dist/Calendar/Calendar.svelte.d.ts +4 -0
- package/dist/Calendar/properties.d.ts +30 -0
- package/dist/Calendar/properties.js +1 -0
- package/dist/Carousel/Carousel.svelte +258 -0
- package/dist/Carousel/Carousel.svelte.d.ts +4 -0
- package/dist/Carousel/properties.d.ts +20 -0
- package/dist/Carousel/properties.js +1 -0
- package/dist/CheckListItem/CheckListItem.svelte +65 -0
- package/dist/CheckListItem/CheckListItem.svelte.d.ts +4 -0
- package/dist/CheckListItem/properties.d.ts +15 -0
- package/dist/CheckListItem/properties.js +1 -0
- package/dist/Checkbox/Checkbox.svelte +157 -0
- package/dist/Checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/Checkbox/properties.d.ts +17 -0
- package/dist/Checkbox/properties.js +1 -0
- package/dist/Choicebox/Choicebox.svelte +85 -0
- package/dist/Choicebox/Choicebox.svelte.d.ts +4 -0
- package/dist/Choicebox/properties.d.ts +14 -0
- package/dist/Choicebox/properties.js +1 -0
- package/dist/ColorPicker/ColorPicker.svelte +583 -0
- package/dist/ColorPicker/ColorPicker.svelte.d.ts +4 -0
- package/dist/ColorPicker/properties.d.ts +15 -0
- package/dist/ColorPicker/properties.js +1 -0
- package/dist/Combobox/Combobox.svelte +432 -0
- package/dist/Combobox/Combobox.svelte.d.ts +6 -0
- package/dist/Combobox/properties.d.ts +42 -0
- package/dist/Combobox/properties.js +1 -0
- package/dist/CommandMenu/CommandMenu.svelte +452 -0
- package/dist/CommandMenu/CommandMenu.svelte.d.ts +4 -0
- package/dist/CommandMenu/properties.d.ts +26 -0
- package/dist/CommandMenu/properties.js +1 -0
- package/dist/ContextMenu/ContextMenu.svelte +308 -0
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +4 -0
- package/dist/ContextMenu/properties.d.ts +26 -0
- package/dist/ContextMenu/properties.js +1 -0
- package/dist/Gauge/Gauge.svelte +70 -0
- package/dist/Gauge/Gauge.svelte.d.ts +4 -0
- package/dist/Gauge/properties.d.ts +9 -0
- package/dist/Gauge/properties.js +1 -0
- package/dist/GridItem/GridItem.svelte +145 -0
- package/dist/GridItem/GridItem.svelte.d.ts +4 -0
- package/dist/GridItem/properties.d.ts +15 -0
- package/dist/GridItem/properties.js +1 -0
- package/dist/Icon/Icon.svelte +61 -0
- package/dist/Icon/Icon.svelte.d.ts +4 -0
- package/dist/Icon/properties.d.ts +12 -0
- package/dist/Icon/properties.js +1 -0
- package/dist/IconStack/IconStack.svelte +55 -0
- package/dist/IconStack/IconStack.svelte.d.ts +4 -0
- package/dist/IconStack/properties.d.ts +9 -0
- package/dist/IconStack/properties.js +1 -0
- package/dist/Img/Img.svelte +37 -0
- package/dist/Img/Img.svelte.d.ts +4 -0
- package/dist/Img/properties.d.ts +13 -0
- package/dist/Img/properties.js +1 -0
- package/dist/Input/Input.svelte +349 -0
- package/dist/Input/Input.svelte.d.ts +8 -0
- package/dist/Input/properties.d.ts +45 -0
- package/dist/Input/properties.js +1 -0
- package/dist/InputButton/InputButton.svelte +252 -0
- package/dist/InputButton/InputButton.svelte.d.ts +7 -0
- package/dist/InputButton/properties.d.ts +22 -0
- package/dist/InputButton/properties.js +1 -0
- package/dist/KeyboardInput/KeyboardInput.svelte +93 -0
- package/dist/KeyboardInput/KeyboardInput.svelte.d.ts +4 -0
- package/dist/KeyboardInput/properties.d.ts +12 -0
- package/dist/KeyboardInput/properties.js +1 -0
- package/dist/ListItem/ListItem.svelte +309 -0
- package/dist/ListItem/ListItem.svelte.d.ts +4 -0
- package/dist/ListItem/properties.d.ts +34 -0
- package/dist/ListItem/properties.js +1 -0
- package/dist/Loader/Loader.svelte +90 -0
- package/dist/Loader/Loader.svelte.d.ts +4 -0
- package/dist/Loader/properties.d.ts +4 -0
- package/dist/Loader/properties.js +1 -0
- package/dist/LoadingDots/LoadingDots.svelte +59 -0
- package/dist/LoadingDots/LoadingDots.svelte.d.ts +3 -0
- package/dist/LoadingDots/properties.d.ts +8 -0
- package/dist/LoadingDots/properties.js +1 -0
- package/dist/Menu/Menu.svelte +356 -0
- package/dist/Menu/Menu.svelte.d.ts +4 -0
- package/dist/Menu/properties.d.ts +28 -0
- package/dist/Menu/properties.js +1 -0
- package/dist/Modal/Modal.svelte +357 -0
- package/dist/Modal/Modal.svelte.d.ts +4 -0
- package/dist/Modal/properties.d.ts +39 -0
- package/dist/Modal/properties.js +1 -0
- package/dist/Pagination/Pagination.svelte +148 -0
- package/dist/Pagination/Pagination.svelte.d.ts +4 -0
- package/dist/Pagination/properties.d.ts +14 -0
- package/dist/Pagination/properties.js +1 -0
- package/dist/Phone/Phone.svelte +234 -0
- package/dist/Phone/Phone.svelte.d.ts +3 -0
- package/dist/Phone/properties.d.ts +11 -0
- package/dist/Phone/properties.js +1 -0
- package/dist/Pill/Pill.svelte +130 -0
- package/dist/Pill/Pill.svelte.d.ts +4 -0
- package/dist/Pill/properties.d.ts +16 -0
- package/dist/Pill/properties.js +1 -0
- package/dist/Progress/Progress.svelte +68 -0
- package/dist/Progress/Progress.svelte.d.ts +4 -0
- package/dist/Progress/properties.d.ts +10 -0
- package/dist/Progress/properties.js +1 -0
- package/dist/Radio/Radio.svelte +124 -0
- package/dist/Radio/Radio.svelte.d.ts +4 -0
- package/dist/Radio/properties.d.ts +15 -0
- package/dist/Radio/properties.js +1 -0
- package/dist/RelativeTime/RelativeTime.svelte +109 -0
- package/dist/RelativeTime/RelativeTime.svelte.d.ts +4 -0
- package/dist/RelativeTime/properties.d.ts +13 -0
- package/dist/RelativeTime/properties.js +1 -0
- package/dist/Scroller/Scroller.svelte +390 -0
- package/dist/Scroller/Scroller.svelte.d.ts +4 -0
- package/dist/Scroller/properties.d.ts +30 -0
- package/dist/Scroller/properties.js +1 -0
- package/dist/Select/Select.svelte +472 -0
- package/dist/Select/Select.svelte.d.ts +4 -0
- package/dist/Select/properties.d.ts +20 -0
- package/dist/Select/properties.js +1 -0
- package/dist/Sheet/Sheet.svelte +264 -0
- package/dist/Sheet/Sheet.svelte.d.ts +4 -0
- package/dist/Sheet/properties.d.ts +19 -0
- package/dist/Sheet/properties.js +1 -0
- package/dist/Shimmer/Shimmer.svelte +44 -0
- package/dist/Shimmer/Shimmer.svelte.d.ts +4 -0
- package/dist/Shimmer/properties.d.ts +4 -0
- package/dist/Shimmer/properties.js +1 -0
- package/dist/Slider/Slider.svelte +147 -0
- package/dist/Slider/Slider.svelte.d.ts +4 -0
- package/dist/Slider/properties.d.ts +17 -0
- package/dist/Slider/properties.js +1 -0
- package/dist/Snippet/Snippet.svelte +123 -0
- package/dist/Snippet/Snippet.svelte.d.ts +4 -0
- package/dist/Snippet/properties.d.ts +15 -0
- package/dist/Snippet/properties.js +1 -0
- package/dist/SplitButton/SplitButton.svelte +145 -0
- package/dist/SplitButton/SplitButton.svelte.d.ts +4 -0
- package/dist/SplitButton/properties.d.ts +17 -0
- package/dist/SplitButton/properties.js +1 -0
- package/dist/SplitInput/SplitInput.svelte +225 -0
- package/dist/SplitInput/SplitInput.svelte.d.ts +7 -0
- package/dist/SplitInput/properties.d.ts +20 -0
- package/dist/SplitInput/properties.js +1 -0
- package/dist/Stepper/Step.svelte +88 -0
- package/dist/Stepper/Step.svelte.d.ts +4 -0
- package/dist/Stepper/Stepper.svelte +64 -0
- package/dist/Stepper/Stepper.svelte.d.ts +4 -0
- package/dist/Stepper/properties.d.ts +27 -0
- package/dist/Stepper/properties.js +1 -0
- package/dist/Table/Table.svelte +357 -0
- package/dist/Table/Table.svelte.d.ts +4 -0
- package/dist/Table/properties.d.ts +26 -0
- package/dist/Table/properties.js +1 -0
- package/dist/Tabs/Tabs.svelte +303 -0
- package/dist/Tabs/Tabs.svelte.d.ts +4 -0
- package/dist/Tabs/properties.d.ts +30 -0
- package/dist/Tabs/properties.js +1 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte +249 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte.d.ts +4 -0
- package/dist/ThemeSwitcher/properties.d.ts +19 -0
- package/dist/ThemeSwitcher/properties.js +1 -0
- package/dist/Toast/Toast.svelte +220 -0
- package/dist/Toast/Toast.svelte.d.ts +4 -0
- package/dist/Toast/properties.d.ts +24 -0
- package/dist/Toast/properties.js +1 -0
- package/dist/Toggle/Toggle.svelte +99 -0
- package/dist/Toggle/Toggle.svelte.d.ts +4 -0
- package/dist/Toggle/properties.d.ts +9 -0
- package/dist/Toggle/properties.js +1 -0
- package/dist/Toolbar/Toolbar.svelte +142 -0
- package/dist/Toolbar/Toolbar.svelte.d.ts +4 -0
- package/dist/Toolbar/properties.d.ts +16 -0
- package/dist/Toolbar/properties.js +1 -0
- package/dist/Tooltip/Tooltip.svelte +153 -0
- package/dist/Tooltip/Tooltip.svelte.d.ts +4 -0
- package/dist/Tooltip/properties.d.ts +13 -0
- package/dist/Tooltip/properties.js +1 -0
- package/dist/assets/back.svg +3 -0
- package/dist/assets/battery.svg +5 -0
- package/dist/assets/checkmark.svg +3 -0
- package/dist/assets/chevron-down-sm.svg +3 -0
- package/dist/assets/chevron-down.svg +3 -0
- package/dist/assets/chevron-left-lg.svg +3 -0
- package/dist/assets/chevron-left.svg +3 -0
- package/dist/assets/chevron-right-lg.svg +3 -0
- package/dist/assets/chevron-right.svg +3 -0
- package/dist/assets/chevron-up.svg +3 -0
- package/dist/assets/close.svg +4 -0
- package/dist/assets/copy.svg +4 -0
- package/dist/assets/error-circle.svg +5 -0
- package/dist/assets/lock.svg +3 -0
- package/dist/assets/minus.svg +3 -0
- package/dist/assets/monitor.svg +5 -0
- package/dist/assets/moon.svg +3 -0
- package/dist/assets/palette.svg +7 -0
- package/dist/assets/search.svg +4 -0
- package/dist/assets/signal.svg +6 -0
- package/dist/assets/sort-default.svg +4 -0
- package/dist/assets/sun.svg +11 -0
- package/dist/assets/swap-vertical.svg +6 -0
- package/dist/assets/wifi.svg +3 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +55 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +28 -0
- package/dist/utils.js +294 -0
- package/package.json +91 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button from '../Button/Button.svelte';
|
|
3
|
+
import Input from '../Input/Input.svelte';
|
|
4
|
+
import type { InputButtonProperties } from './properties';
|
|
5
|
+
import type { ValidationState } from '../types';
|
|
6
|
+
import type { SvelteComponent } from 'svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
value = $bindable(''),
|
|
10
|
+
inputProperties,
|
|
11
|
+
rightButtonProperties,
|
|
12
|
+
leftButtonProperties,
|
|
13
|
+
bottomButtonProperties,
|
|
14
|
+
inputEventProperties,
|
|
15
|
+
rightButtonEventProperties,
|
|
16
|
+
leftButtonEventProperties,
|
|
17
|
+
bottomButtonEventProperties,
|
|
18
|
+
leftIcon,
|
|
19
|
+
rightIcon,
|
|
20
|
+
testId,
|
|
21
|
+
classes
|
|
22
|
+
}: InputButtonProperties = $props();
|
|
23
|
+
|
|
24
|
+
let validationState = $state<ValidationState>('InProgress');
|
|
25
|
+
|
|
26
|
+
let inputRef: SvelteComponent | null = $state(null);
|
|
27
|
+
|
|
28
|
+
// Derive enable state for right button
|
|
29
|
+
const isRightButtonEnabled = $derived(validationState === 'Valid');
|
|
30
|
+
|
|
31
|
+
function rightButtonClick(event: MouseEvent): void {
|
|
32
|
+
if (validationState === 'Valid') {
|
|
33
|
+
rightButtonEventProperties?.onclick?.(event);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function bottomButtonClick(event: MouseEvent): void {
|
|
38
|
+
if (validationState === 'Valid') {
|
|
39
|
+
bottomButtonEventProperties?.onclick?.(event);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function triggerRightClickIfValid(event: KeyboardEvent): void {
|
|
44
|
+
if (event?.key === 'Enter' && validationState === 'Valid') {
|
|
45
|
+
rightButtonEventProperties?.onkeyup?.(event);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleStateChange(state: ValidationState): void {
|
|
50
|
+
validationState = state;
|
|
51
|
+
inputEventProperties?.onstatechange?.(state);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function focus() {
|
|
55
|
+
inputRef?.focus();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function blur() {
|
|
59
|
+
inputRef?.blur();
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<div class="container {classes ?? ''}" data-pw={testId}>
|
|
64
|
+
{#if inputProperties.label && inputProperties.label !== ''}
|
|
65
|
+
<label class="label" for={inputProperties.name}>
|
|
66
|
+
{inputProperties.label}
|
|
67
|
+
</label>
|
|
68
|
+
{/if}
|
|
69
|
+
|
|
70
|
+
<div class="input-button-container">
|
|
71
|
+
<div class="input-button {validationState === 'Invalid' ? 'invalid' : 'valid'}">
|
|
72
|
+
{#if leftButtonProperties != null}
|
|
73
|
+
<div class="left-button">
|
|
74
|
+
<Button {...leftButtonProperties} {...leftButtonEventProperties} icon={leftIcon} />
|
|
75
|
+
</div>
|
|
76
|
+
{/if}
|
|
77
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
78
|
+
<div class="input" onkeyup={triggerRightClickIfValid}>
|
|
79
|
+
<Input
|
|
80
|
+
{...inputProperties}
|
|
81
|
+
{...inputEventProperties}
|
|
82
|
+
bind:value
|
|
83
|
+
bind:this={inputRef}
|
|
84
|
+
onstatechange={handleStateChange}
|
|
85
|
+
actionInput={true}
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
{#if rightButtonProperties != null}
|
|
89
|
+
<div class="right-button">
|
|
90
|
+
<Button
|
|
91
|
+
{...rightButtonProperties}
|
|
92
|
+
enable={isRightButtonEnabled}
|
|
93
|
+
onclick={rightButtonClick}
|
|
94
|
+
icon={rightIcon}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
{/if}
|
|
98
|
+
</div>
|
|
99
|
+
{#if bottomButtonProperties != null}
|
|
100
|
+
<div class="bottom-button">
|
|
101
|
+
<Button {...bottomButtonProperties} onclick={bottomButtonClick} />
|
|
102
|
+
</div>
|
|
103
|
+
{/if}
|
|
104
|
+
</div>
|
|
105
|
+
{#if inputProperties.onErrorMessage !== '' && validationState === 'Invalid'}
|
|
106
|
+
<div class="error-message">
|
|
107
|
+
{inputProperties.onErrorMessage}
|
|
108
|
+
</div>
|
|
109
|
+
{/if}
|
|
110
|
+
{#if inputProperties.infoMessage !== ''}
|
|
111
|
+
<div class="info-message">
|
|
112
|
+
{inputProperties.infoMessage}
|
|
113
|
+
</div>
|
|
114
|
+
{/if}
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<style>
|
|
118
|
+
.container {
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
margin: var(--input-button-container-margin);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.input-button-container {
|
|
125
|
+
--button-width: 100%;
|
|
126
|
+
--input-border: none;
|
|
127
|
+
--input-focus-border: none;
|
|
128
|
+
--input-box-shadow: none;
|
|
129
|
+
--input-margin: none;
|
|
130
|
+
--input-width: fit-content;
|
|
131
|
+
height: var(--input-height, fit-content);
|
|
132
|
+
font-size: var(--input-font-size, 16px) !important;
|
|
133
|
+
font-weight: 500;
|
|
134
|
+
margin: var(--input-button-margin);
|
|
135
|
+
border-radius: var(--input-button-radius, 6px);
|
|
136
|
+
border: var(--input-button-container-border);
|
|
137
|
+
background: var(--input-button-container-background);
|
|
138
|
+
padding: var(--input-button-container-padding);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.input-button {
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: stretch;
|
|
144
|
+
border-radius: var(--input-button-radius, 6px);
|
|
145
|
+
border: var(--input-button-border, 1px solid currentColor);
|
|
146
|
+
box-shadow: var(--input-button-box-shadow, none);
|
|
147
|
+
background: var(--input-button-background);
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
}
|
|
150
|
+
.input-button-container:focus-within {
|
|
151
|
+
border: var(--input-button-focus-border);
|
|
152
|
+
}
|
|
153
|
+
.input {
|
|
154
|
+
flex: 2;
|
|
155
|
+
min-width: 0px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.bottom-button {
|
|
159
|
+
padding: var(--input-bottom-btn-padding, 10px 0px);
|
|
160
|
+
--button-cursor: var(--input-button-bottom-cursor);
|
|
161
|
+
--button-color: var(--input-button-bottom-color);
|
|
162
|
+
--button-text-color: var(--input-button-bottom-text-color);
|
|
163
|
+
--button-font-family: var(--input-button-bottom-font-family);
|
|
164
|
+
--button-font-weight: var(--input-button-bottom-font-weight);
|
|
165
|
+
--button-font-size: var(--input-button-bottom-font-size);
|
|
166
|
+
--button-height: var(--input-button-bottom-height, 54px);
|
|
167
|
+
--button-padding: var(--input-button-bottom-padding);
|
|
168
|
+
--button-border-radius: var(--input-button-bottom-border-radius);
|
|
169
|
+
--button-width: var(--input-button-bottom-width);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.label {
|
|
173
|
+
font-weight: var(--input-label-msg-text-weight, 400);
|
|
174
|
+
font-size: var(--input-label-msg-text-size, 12px);
|
|
175
|
+
color: var(--input-label-msg-text-color, currentColor);
|
|
176
|
+
line-height: var(--input-label-msg-text-line-height);
|
|
177
|
+
margin: var(--input-label-msg-text-margin, 0px 0px 6px 0px);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.invalid {
|
|
181
|
+
outline: var(--invalid-outline, 1px solid var(--input-field-error-stroke, currentColor));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.error-message {
|
|
185
|
+
font-weight: var(--input-error-msg-text-weight, 400);
|
|
186
|
+
font-size: var(--input-error-msg-text-size, 12px);
|
|
187
|
+
color: var(--input-error-msg-text-color, currentColor);
|
|
188
|
+
margin: var(--input-btn-error-msg-margin, 12px 0px 0px 0px);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.info-message {
|
|
192
|
+
font-weight: var(--input-info-msg-text-weight, 400);
|
|
193
|
+
font-size: var(--input-info-msg-text-size, 12px);
|
|
194
|
+
color: var(--input-info-msg-text-color, currentColor);
|
|
195
|
+
margin: var(--input-btn-info-msg-margin, 12px 0px 0px 0px);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.left-button {
|
|
199
|
+
--button-color: var(--input-button-left-color);
|
|
200
|
+
--button-text-color: var(--input-button-left-text-color);
|
|
201
|
+
--button-font-family: var(--input-button-left-font-family);
|
|
202
|
+
--button-font-weight: var(--input-button-left-font-weight);
|
|
203
|
+
--button-font-size: var(--input-button-left-font-size);
|
|
204
|
+
--button-height: var(--input-button-left-height, 100%);
|
|
205
|
+
--button-padding: var(--input-button-left-padding, 0px 16px);
|
|
206
|
+
--button-border-radius: var(--input-button-left-border-radius);
|
|
207
|
+
--button-width: var(--input-button-left-width);
|
|
208
|
+
--button-cursor: var(--input-button-left-cursor);
|
|
209
|
+
--button-opacity: var(--input-button-left-opacity);
|
|
210
|
+
--button-border: var(--input-button-left-border);
|
|
211
|
+
display: flex;
|
|
212
|
+
justify-content: center;
|
|
213
|
+
align-items: stretch;
|
|
214
|
+
flex-direction: row;
|
|
215
|
+
--button-content-gap: var(--input-button-left-content-gap);
|
|
216
|
+
--button-content-flex-direction: var(--input-button-left-content-flex-direction, row);
|
|
217
|
+
--button-icon-order: var(--input-button-left-icon-order);
|
|
218
|
+
--button-icon-display: var(--input-button-left-icon-display);
|
|
219
|
+
--button-text-order: var(--input-button-left-text-order);
|
|
220
|
+
--button-disabled-cursor: var(--input-button-left-disabled-cursor);
|
|
221
|
+
--button-disabled-opacity: var(--input-button-left-disabled-opacity);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.right-button {
|
|
225
|
+
flex: var(--input-button-right-flex, 1);
|
|
226
|
+
display: flex;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
align-items: stretch;
|
|
229
|
+
flex-direction: row;
|
|
230
|
+
min-width: var(--input-button-right-min-width, 0px);
|
|
231
|
+
--button-color: var(--input-button-right-color);
|
|
232
|
+
--button-text-color: var(--input-button-right-text-color);
|
|
233
|
+
--button-font-family: var(--input-button-right-font-family);
|
|
234
|
+
--button-font-weight: var(--input-button-right-font-weight);
|
|
235
|
+
--button-font-size: var(--input-button-right-font-size);
|
|
236
|
+
--button-height: var(--input-button-right-height, 100%);
|
|
237
|
+
--button-padding: var(--input-button-right-padding, 0px 16px);
|
|
238
|
+
--button-border-radius: var(--input-button-right-border-radius, 0px 6px 6px 0px);
|
|
239
|
+
--button-width: var(--input-button-right-width, 100%);
|
|
240
|
+
--button-cursor: var(--input-button-right-cursor);
|
|
241
|
+
--button-opacity: var(--input-button-right-opacity);
|
|
242
|
+
--button-border: var(--input-button-right-border);
|
|
243
|
+
--button-content-gap: var(--input-button-right-content-gap);
|
|
244
|
+
--button-visibility: var(--input-button-right-visibility, visible);
|
|
245
|
+
--button-content-flex-direction: var(--input-button-right-content-flex-direction, row);
|
|
246
|
+
--button-icon-order: var(--input-button-right-icon-order);
|
|
247
|
+
--button-icon-display: var(--input-button-right-icon-display);
|
|
248
|
+
--button-text-order: var(--input-button-right-text-order);
|
|
249
|
+
--button-disabled-cursor: var(--input-button-right-disabled-cursor);
|
|
250
|
+
--button-disabled-opacity: var(--input-button-right-disabled-opacity);
|
|
251
|
+
}
|
|
252
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InputButtonProperties } from './properties';
|
|
2
|
+
declare const InputButton: import("svelte").Component<InputButtonProperties, {
|
|
3
|
+
focus: () => void;
|
|
4
|
+
blur: () => void;
|
|
5
|
+
}, "value">;
|
|
6
|
+
type InputButton = ReturnType<typeof InputButton>;
|
|
7
|
+
export default InputButton;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ButtonEventProperties, OptionalButtonProperties } from '../Button/properties';
|
|
2
|
+
import type { InputEventProperties, OptionalInputProperties } from '../Input/properties';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
export type InputButtonProperties = OptionalInputButtonProperties & InputButtonEventProperties & {
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
export type OptionalInputButtonProperties = {
|
|
8
|
+
inputProperties: OptionalInputProperties;
|
|
9
|
+
rightButtonProperties?: OptionalButtonProperties | null;
|
|
10
|
+
leftButtonProperties?: OptionalButtonProperties | null;
|
|
11
|
+
bottomButtonProperties?: OptionalButtonProperties | null;
|
|
12
|
+
leftIcon?: Snippet;
|
|
13
|
+
rightIcon?: Snippet;
|
|
14
|
+
testId?: string;
|
|
15
|
+
classes?: string;
|
|
16
|
+
};
|
|
17
|
+
export type InputButtonEventProperties = {
|
|
18
|
+
inputEventProperties?: InputEventProperties;
|
|
19
|
+
rightButtonEventProperties?: ButtonEventProperties | null;
|
|
20
|
+
leftButtonEventProperties?: ButtonEventProperties | null;
|
|
21
|
+
bottomButtonEventProperties?: ButtonEventProperties | null;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { KeyboardInputProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let { keys, separator = '+', testId, onclick, classes }: KeyboardInputProperties = $props();
|
|
5
|
+
|
|
6
|
+
const KEY_SYMBOLS: Record<string, string> = {
|
|
7
|
+
cmd: '\u2318',
|
|
8
|
+
command: '\u2318',
|
|
9
|
+
ctrl: '\u2303',
|
|
10
|
+
control: '\u2303',
|
|
11
|
+
alt: '\u2325',
|
|
12
|
+
option: '\u2325',
|
|
13
|
+
shift: '\u21E7',
|
|
14
|
+
enter: '\u21B5',
|
|
15
|
+
backspace: '\u232B',
|
|
16
|
+
delete: '\u2326',
|
|
17
|
+
tab: '\u21E5',
|
|
18
|
+
escape: 'Esc',
|
|
19
|
+
esc: 'Esc',
|
|
20
|
+
up: '\u2191',
|
|
21
|
+
down: '\u2193',
|
|
22
|
+
left: '\u2190',
|
|
23
|
+
right: '\u2192',
|
|
24
|
+
space: '\u2423'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let keyList = $derived(Array.isArray(keys) ? keys : keys.split(separator).map((k) => k.trim()));
|
|
28
|
+
let interactive = $derived(typeof onclick === 'function');
|
|
29
|
+
|
|
30
|
+
function getSymbol(key: string): string {
|
|
31
|
+
return KEY_SYMBOLS[key.toLowerCase()] ?? key;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function handleKeydown(event: KeyboardEvent): void {
|
|
35
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
onclick?.(new MouseEvent('click'));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
43
|
+
<span
|
|
44
|
+
class="keyboard-input {classes ?? ''}"
|
|
45
|
+
data-pw={testId}
|
|
46
|
+
onclick={interactive ? onclick : null}
|
|
47
|
+
onkeydown={interactive ? handleKeydown : null}
|
|
48
|
+
role={interactive ? 'button' : null}
|
|
49
|
+
tabindex={interactive ? 0 : null}
|
|
50
|
+
>
|
|
51
|
+
{#each keyList as key, i (i)}
|
|
52
|
+
{#if i > 0}
|
|
53
|
+
<span class="separator">{separator}</span>
|
|
54
|
+
{/if}
|
|
55
|
+
<kbd class="key">{getSymbol(key)}</kbd>
|
|
56
|
+
{/each}
|
|
57
|
+
</span>
|
|
58
|
+
|
|
59
|
+
<style>
|
|
60
|
+
.keyboard-input {
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: var(--keyboard-input-gap, 4px);
|
|
64
|
+
font-family: var(--keyboard-input-font-family, inherit);
|
|
65
|
+
font-size: var(--keyboard-input-font-size, 14px);
|
|
66
|
+
vertical-align: baseline;
|
|
67
|
+
cursor: var(--keyboard-input-cursor, default);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.separator {
|
|
71
|
+
color: var(--keyboard-input-separator-color, currentColor);
|
|
72
|
+
font-size: var(--keyboard-input-separator-font-size, 0.85em);
|
|
73
|
+
user-select: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.key {
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
font-family: var(--keyboard-input-key-font-family, inherit);
|
|
81
|
+
font-weight: var(--keyboard-input-key-font-weight, 500);
|
|
82
|
+
color: var(--keyboard-input-key-color, currentColor);
|
|
83
|
+
background-color: var(--keyboard-input-key-background, transparent);
|
|
84
|
+
border: var(--keyboard-input-key-border, 1px solid currentColor);
|
|
85
|
+
border-radius: var(--keyboard-input-key-border-radius, 6px);
|
|
86
|
+
box-shadow: var(--keyboard-input-key-box-shadow, 0 1px 0 currentColor);
|
|
87
|
+
min-width: var(--keyboard-input-key-min-width, 1.6em);
|
|
88
|
+
padding: var(--keyboard-input-key-padding, 2px 6px);
|
|
89
|
+
text-align: center;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
line-height: 1;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type KeyboardInputProperties = MandatoryKeyboardInputProperties & OptionalKeyboardInputProperties & KeyboardInputEventProperties;
|
|
2
|
+
export type MandatoryKeyboardInputProperties = {
|
|
3
|
+
keys: string[] | string;
|
|
4
|
+
};
|
|
5
|
+
export type OptionalKeyboardInputProperties = {
|
|
6
|
+
separator?: string;
|
|
7
|
+
testId?: string;
|
|
8
|
+
classes?: string;
|
|
9
|
+
};
|
|
10
|
+
export type KeyboardInputEventProperties = {
|
|
11
|
+
onclick?: (event: MouseEvent) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|